asar coverage - build #299


src/asar/
File: src/asar/frozen/bits/hash_string.h
Date: 2025-03-15 23:40:07
Lines:
5/5
100.0%
Functions:
2/2
100.0%
Branches:
4/4
100.0%

Line Branch Exec Source
1 #ifndef FROZEN_LETITGO_BITS_HASH_STRING_H
2 #define FROZEN_LETITGO_BITS_HASH_STRING_H
3
4 #include <cstddef>
5
6 namespace frozen {
7
8 template <typename String>
9 constexpr std::size_t hash_string(const String& value) {
10 std::size_t d = 5381;
11 for (const auto& c : value)
12 d = d * 33 + static_cast<std::size_t>(c);
13 return d;
14 }
15
16 // https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
17 // With the lowest bits removed, based on experimental setup.
18 template <typename String>
19 97871 constexpr std::size_t hash_string(const String& value, std::size_t seed) {
20 97871 std::size_t d = (0x811c9dc5 ^ seed) * static_cast<std::size_t>(0x01000193);
21
4/4
✓ Branch 0 taken 244567 times.
✓ Branch 1 taken 48454 times.
✓ Branch 2 taken 248065 times.
✓ Branch 3 taken 49417 times.
590503 for (const auto& c : value)
22 492632 d = (d ^ static_cast<std::size_t>(c)) * static_cast<std::size_t>(0x01000193);
23 97871 return d >> 8 ;
24 }
25
26 } // namespace frozen
27
28 #endif // FROZEN_LETITGO_BITS_HASH_STRING_H
29