Skip to content

Commit

Permalink
[LookupTables1] Simplified comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
dendibakh committed Sep 17, 2024
1 parent 34cfd84 commit e347756
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions labs/bad_speculation/lookup_tables_1/solution.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "solution.hpp"

static std::size_t mapToBucket(std::size_t v) { // diff
if (v >= 0 && v < 13) return 0; // 13
else if (v >= 13 && v < 29) return 1; // 16
else if (v >= 29 && v < 41) return 2; // 12
else if (v >= 41 && v < 53) return 3; // 12
else if (v >= 53 && v < 71) return 4; // 18
else if (v >= 71 && v < 83) return 5; // 12
else if (v >= 83 && v < 100) return 6; // 17
static std::size_t mapToBucket(std::size_t v) {
// size of a bucket
if (v < 13) return 0; // 13
else if (v < 29) return 1; // 16
else if (v < 41) return 2; // 12
else if (v < 53) return 3; // 12
else if (v < 71) return 4; // 18
else if (v < 83) return 5; // 12
else if (v < 100) return 6; // 17
return -1; // let it crash
}

Expand Down

0 comments on commit e347756

Please sign in to comment.