Browse Source

feat: try to reduce repeated hash searches

master
Dnomd343 2 years ago
parent
commit
8f03dc024f
  1. 74
      src/analyse/analyse.cc

74
src/analyse/analyse.cc

@ -11,27 +11,8 @@ Core Analyse::new_core() {
);
}
class test_c {
public:
test_c() {
std::cout << "class init" << std::endl;
}
};
struct test_t {
uint64_t data;
test_c demo;
};
void Analyse::start_analyse(uint64_t code) {
auto t = test_t {
.data = 123,
// data: 123,
};
return;
auto core = new_core();
cases.empty();
@ -43,14 +24,9 @@ void Analyse::start_analyse(uint64_t code) {
.code = code,
.mask = 0,
.step = 0,
// .src = std::move(std::vector<analyse_t*>{}),
.src = std::move(std::list<analyse_t*>{}),
// .src = std::move(std::set<analyse_t*>{}),
// .src = std::move(std::unordered_set<analyse_t*>{}),
// .src = std::move(std::list<analyse_t*>{}),
}).first->second);
// std::cout << "src size: " << cases[code].src.size() << std::endl;
while (!cache.empty()) {
core.next_step(cache.front()->code, cache.front()->mask);
@ -62,27 +38,41 @@ void Analyse::start_analyse(uint64_t code) {
}
void Analyse::new_case(uint64_t code, uint64_t mask) {
auto current = cases.find(code);
if (current != cases.end()) { // find existed case
current->second.mask |= mask; // update mask info
// current->second.src.emplace()
if (current->second.step != cache.front()->step) {
// current->second.src.emplace(cache.front());
current->second.src.push_back(cache.front());
auto temp = cases.emplace(code, analyse_t {
.code = code,
.mask = mask,
.step = cache.front()->step + 1,
.src = std::move(std::list<analyse_t*>{cache.front()})
});
if (temp.second) {
cache.emplace(&temp.first->second);
} else {
temp.first->second.mask |= mask;
if (temp.first->second.step != cache.front()->step) {
temp.first->second.src.push_back(cache.front());
}
return;
}
cache.emplace(&cases.emplace(code, analyse_t {
.code = code,
.mask = mask,
.step = cache.front()->step + 1,
// .src = std::move(std::vector<analyse_t*>{cache.front()}),
.src = std::move(std::list<analyse_t*>{cache.front()}),
// .src = std::move(std::set<analyse_t*>{cache.front()}),
// .src = std::move(std::unordered_set<analyse_t*>{cache.front()}),
}).first->second);
// auto current = cases.find(code);
// if (current != cases.end()) { // find existed case
// current->second.mask |= mask; // update mask info
//
// if (current->second.step != cache.front()->step) {
// current->second.src.push_back(cache.front());
// }
//
// return;
// }
//
// cache.emplace(&cases.emplace(code, analyse_t {
// .code = code,
// .mask = mask,
// .step = cache.front()->step + 1,
// .src = std::move(std::list<analyse_t*>{cache.front()}),
// }).first->second);
}

Loading…
Cancel
Save