File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,15 +15,17 @@ namespace hat::detail {
1515#ifdef LIBHAT_HINT_X86_64
1616 const bool x86_64 = static_cast <bool >(this ->hints & scan_hint::x86_64);
1717 if (x86_64 && !pair0 && scanner.vectorSize ) {
18- static constexpr auto getScore = [](const std::byte a, const std::byte b) {
18+ static constexpr auto getScore = [](const std::byte a, const std::byte b) -> uint16_t {
1919 constexpr auto & pairs = hat::detail::x86_64::pairs_x1;
20+ constexpr auto & scores = hat::detail::x86_64::scores_x1;
21+ static_assert (pairs.size () == scores.size ());
22+
23+ constexpr auto max = static_cast <uint16_t >(scores.size ());
24+
2025 const std::pair pair{a, b};
2126 const auto it = std::ranges::lower_bound (pairs, pair);
2227 const auto index = static_cast <uint16_t >(it - pairs.begin ());
23- if (it != pairs.end () && *it == pair) {
24- return hat::detail::x86_64::scores_x1[index];
25- }
26- return index;
28+ return it != pairs.end () && *it == pair ? scores[index] : max;
2729 };
2830
2931 std::optional<std::pair<size_t , uint16_t >> bestPair{};
You can’t perform that action at this time.
0 commit comments