diff --git a/src/fast_cal/fast_cal.cc b/src/fast_cal/fast_cal.cc index 5842549..71d7cbb 100644 --- a/src/fast_cal/fast_cal.cc +++ b/src/fast_cal/fast_cal.cc @@ -6,13 +6,25 @@ #include -void FastCal::fast_cal(uint64_t code) { +void FastCal::new_case(uint64_t code, uint64_t mask) { // callback function for new case + auto current = cases.find(code); + if (current != cases.end()) { // find existed case + current->second.mask |= mask; // update mask info + return; + } + cases[code] = fast_cal_t { // insert into cases map + .code = code, + .mask = mask, + .last = cache.front(), // parent case + }; + cache.emplace(&cases[code]); // add in working queue +} -// std::cout << RawCode(code).dump_case() << std::endl; +void FastCal::fast_cal(uint64_t code) { auto core = Core( [this](auto &&code, auto &&mask) { // lambda as function pointer - add_new_case(std::forward(code), std::forward(mask)); + new_case(std::forward(code), std::forward(mask)); } ); @@ -47,22 +59,3 @@ void FastCal::fast_cal(uint64_t code) { } } - -void FastCal::add_new_case(uint64_t code, uint64_t mask) { - - auto exist_case = cases.find(code); - if (exist_case != cases.end()) { // find existed case - - exist_case->second.mask |= mask; // mask update - return; - - } - - cases[code] = fast_cal_t { - .code = code, - .mask = mask, - .last = cache.front(), - }; - cache.emplace(&cases[code]); - -} diff --git a/src/fast_cal/fast_cal.h b/src/fast_cal/fast_cal.h index f8dbc68..5d8108f 100644 --- a/src/fast_cal/fast_cal.h +++ b/src/fast_cal/fast_cal.h @@ -17,6 +17,6 @@ public: void fast_cal(uint64_t code); - void add_new_case(uint64_t code, uint64_t mask); + void new_case(uint64_t code, uint64_t mask); }; diff --git a/src/main.cc b/src/main.cc index 5154e46..f077aec 100644 --- a/src/main.cc +++ b/src/main.cc @@ -211,24 +211,9 @@ int main() { // } -// BasicRanges::build(); -// for (auto const &range : *BasicRanges::fetch()) { -// printf("%08X\n", range); -// } - -// AllCases::build(); -// for (uint32_t head = 0; head < 16; ++head) { -// uint64_t prefix = (uint64_t)head << 32; -// for (auto const &range : (*AllCases::fetch())[head]) { -// printf("%09lX\n", prefix | range); -// } -// } - // std::cout << (clock() - start_time) * 1000 / CLOCKS_PER_SEC << "ms" << std::endl; std::cout << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; // std::cout << "complete benchmark" << std::endl; -// while(1); - return 0; }