Skip to content

Commit 508687c

Browse files
Copilotjll63
andcommitted
Use anonymous namespace for uintptr definitions
Co-authored-by: jll63 <[email protected]>
1 parent 2a31457 commit 508687c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

include/boost/openmethod/policies/minimal_perfect_hash.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#pragma warning(disable : 4702) // unreachable code
1818
#endif
1919

20-
namespace boost::openmethod::detail {
20+
namespace {
2121

2222
#if defined(UINTPTR_MAX)
2323
using uintptr = std::uintptr_t;
@@ -30,7 +30,7 @@ using uintptr = std::size_t;
3030
constexpr uintptr uintptr_max = (std::numeric_limits<std::size_t>::max)();
3131
#endif
3232

33-
} // namespace boost::openmethod::detail
33+
} // anonymous namespace
3434

3535
namespace boost::openmethod {
3636

@@ -142,8 +142,8 @@ struct minimal_perfect_hash : type_hash {
142142
//! @return The hash value
143143
BOOST_FORCEINLINE
144144
static auto hash(type_id type) -> std::size_t {
145-
auto pilot = (mult * reinterpret_cast<detail::uintptr>(type)) >> shift;
146-
auto group = (group_mult * reinterpret_cast<detail::uintptr>(type)) >> group_shift;
145+
auto pilot = (mult * reinterpret_cast<uintptr>(type)) >> shift;
146+
auto group = (group_mult * reinterpret_cast<uintptr>(type)) >> group_shift;
147147
auto index = (pilot + detail::minimal_perfect_hash_displacements<Registry>[group]) % table_size;
148148

149149
if constexpr (Registry::has_runtime_checks) {
@@ -289,13 +289,13 @@ void minimal_perfect_hash::fn<Registry>::initialize(
289289
// Partition keys into groups
290290
std::vector<std::vector<type_id>> groups(num_groups);
291291
for (auto key : keys) {
292-
auto group_idx = ((group_mult * reinterpret_cast<detail::uintptr>(key)) >> group_shift) % num_groups;
292+
auto group_idx = ((group_mult * reinterpret_cast<uintptr>(key)) >> group_shift) % num_groups;
293293
groups[group_idx].push_back(key);
294294
}
295295

296296
// Try to find displacements for each group
297297
detail::minimal_perfect_hash_displacements<Registry>.assign(num_groups, 0);
298-
buckets.assign(table_size, type_id(detail::uintptr_max));
298+
buckets.assign(table_size, type_id(uintptr_max));
299299
std::vector<bool> used(table_size, false);
300300
bool success = true;
301301

@@ -324,7 +324,7 @@ void minimal_perfect_hash::fn<Registry>::initialize(
324324
positions.reserve(groups[g].size());
325325
bool valid = true;
326326
for (auto key : groups[g]) {
327-
auto pilot = (mult * reinterpret_cast<detail::uintptr>(key)) >> shift;
327+
auto pilot = (mult * reinterpret_cast<uintptr>(key)) >> shift;
328328
auto pos = (pilot + disp) % table_size;
329329
if (used[pos]) {
330330
valid = false;
@@ -354,7 +354,7 @@ void minimal_perfect_hash::fn<Registry>::initialize(
354354
// Count how many positions are used
355355
std::size_t used_count = 0;
356356
for (std::size_t i = 0; i < table_size; ++i) {
357-
if (detail::uintptr(buckets[i]) != detail::uintptr_max) {
357+
if (uintptr(buckets[i]) != uintptr_max) {
358358
used_count++;
359359
}
360360
}

0 commit comments

Comments
 (0)