Browse Source

perf: using `std::stable_sort` instead of `std::sort`

legacy
Dnomd343 2 years ago
parent
commit
dfa8184b5b
  1. 3
      src/all_cases/basic_ranges.cc
  2. 4
      src/main.cc

3
src/all_cases/basic_ranges.cc

@ -51,7 +51,7 @@ void BasicRanges::build_data() { // build basic ranges
}
}
}
std::sort(BasicRanges::data.begin(), BasicRanges::data.end()); // sort basic ranges
std::stable_sort(BasicRanges::data.begin(), BasicRanges::data.end()); // sort basic ranges
for (auto &range : BasicRanges::data) {
range = Common::range_reverse(range); // basic ranges reverse
}
@ -84,7 +84,6 @@ void BasicRanges::generate(generate_t info) { // generate specific basic ranges
cache.pop();
continue; // skip search
}
if (current.nx & 0xFF) { // n1 -> `00`
cache.emplace(build_t {
.nx = current.nx - 0x01, // --n1

4
src/main.cc

@ -245,7 +245,7 @@ int main() {
// }
// BasicRanges::build();
BasicRanges::build();
// const auto &br = BasicRanges::fetch();
// br.push_back(123);
// std::cout << "size: " << BasicRanges::fetch().size() << std::endl;
@ -270,7 +270,7 @@ int main() {
// }
// printf("%09lX\n", ShortCode::tiny_decode_demo(14323231));
std::cout << ShortCode::tiny_encode_demo(0x6EC0F8800) << std::endl;
// std::cout << ShortCode::tiny_encode_demo(0x6EC0F8800) << std::endl;
// auto br = BasicRanges::fetch();
// for (auto &range : br) {

Loading…
Cancel
Save