[libcxx-commits] [libcxx] bc3bc74 - [libc++] Remove a redundant check from __hash_table::__emplace_unique (#162856)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 16 00:33:24 PDT 2025
Author: Nikolas Klauser
Date: 2025-10-16T09:33:20+02:00
New Revision: bc3bc74160bb250c61c171c96f7512bbc70327a3
URL: https://github.com/llvm/llvm-project/commit/bc3bc74160bb250c61c171c96f7512bbc70327a3
DIFF: https://github.com/llvm/llvm-project/commit/bc3bc74160bb250c61c171c96f7512bbc70327a3.diff
LOG: [libc++] Remove a redundant check from __hash_table::__emplace_unique (#162856)
The `|| __bc == 0` case will never be relevant, since we know that
`size() + 1` will always be exactly 1 if `__bc == 0` and `0 *
max_load_factor()` will be zero, so the branch will already be taken due
to the first condition.
Added:
Modified:
libcxx/include/__hash_table
Removed:
################################################################################
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 74923ddb74e9c..6b65e738fef3b 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -808,7 +808,7 @@ public:
}
{
__node_holder __h = __construct_node_hash(__hash, std::forward<_Args>(__args2)...);
- if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
+ if (size() + 1 > __bc * max_load_factor()) {
__rehash_unique(std::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
More information about the libcxx-commits
mailing list