From 04b38e897d49d46a8861803582835f4753b12c96 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Thu, 12 Jan 2023 00:19:32 +0800 Subject: [PATCH] perf: bfs root aka `cache[0]` static --- src/core/bfs.h | 6 ++---- src/core/core.cc | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/bfs.h b/src/core/bfs.h index fa09c6f..528e4b5 100644 --- a/src/core/bfs.h +++ b/src/core/bfs.h @@ -3,10 +3,8 @@ #define BFS_INIT \ int next_addr; \ cache_size = 1; \ -int current = 0; \ -cache[0].filter = 0; \ -cache[0].addr = addr; \ -cache[0].code = code; +int current = 0; \ +cache[0].addr = addr; #define BFS_LOAD \ code = cache[current].code; \ diff --git a/src/core/core.cc b/src/core/core.cc index cc7bf6e..8e7c8bc 100644 --- a/src/core/core.cc +++ b/src/core/core.cc @@ -138,7 +138,11 @@ void Core::next_step(uint64_t raw_code, uint64_t mask) { // search next step cas auto range = raw_code | mask; + cache[0].filter = 0; + cache[0].code = raw_code; + for (int addr = 0; range; addr += 3, range >>= 3) { // traverse every 3-bits +// cache[0].addr = addr; switch (range & 0b111) { // match low 3-bits case B_1x1: move_1x1(raw_code, addr); // try to move 1x1 block