diff options
author | Abseil Team <absl-team@google.com> | 2021-05-18 07:41:30 -0700 |
---|---|---|
committer | rogeeff <rogeeff@google.com> | 2021-05-18 17:44:37 -0400 |
commit | 5de90e2673bd0c19de67c68e2fe543444dc1114a (patch) | |
tree | 61c8ecf4ff9aeb5c59e6884b9a62f5d4a8a6d909 /absl/container/internal/raw_hash_set.h | |
parent | aad2c8a3966424bbaa2f26027d104d17f9c1c1ae (diff) | |
download | abseil-5de90e2673bd0c19de67c68e2fe543444dc1114a.tar.gz abseil-5de90e2673bd0c19de67c68e2fe543444dc1114a.tar.bz2 abseil-5de90e2673bd0c19de67c68e2fe543444dc1114a.zip |
Export of internal Abseil changes
--
30af50146f07d7afdb196abf235f44ec44ea6409 by Derek Mauro <dmauro@google.com>:
Update Abseil dependency versions
PiperOrigin-RevId: 374415690
--
6a241e9ea8ee201789bb66aadf9e1ca9cc23c5dc by Derek Mauro <dmauro@google.com>:
Fix the install test project, which is doing a mixed-mode build.
This manifests in failure with GCC 11, which defaults to C++17
Also explicitly reference python3 in the test script.
python2 is being removed by some Linux distros.
PiperOrigin-RevId: 374278107
--
42f85122407e799183880e0b2e2a71f6d35ee003 by Evan Brown <ezb@google.com>:
Use `capacity + Group::kWidth` control bytes instead of `capacity + Group::kWidth + 1`.
We don't use the extra byte - we only need the first `capacity` ones that are valid, the one sentinel byte and then `Group::kWidth - 1` cloned control bytes. For example, in `EmptyGroup()`, where capacity is 0, we use `Group::kWidth` control bytes.
We need to update set_ctrl() to only mirror `Group::kWidth - 1` bytes instead of `Group::kWidth` bytes.
Note: this doesn't actually save memory unless `alignof(value_type)` is one.
Also add/update related comments.
PiperOrigin-RevId: 374198589
--
5dcd09b2221bf23add583541769b476dac54e112 by Evan Brown <ezb@google.com>:
Improve b-tree value_comp() support.
- Don't expose internal adapted comparator functionality.
- Support value_comp() for maps using function pointer comparators.
- For maps, make value_compare's constructor and the member comparator be protected - [reference](https://en.cppreference.com/w/cpp/container/map/value_compare).
PiperOrigin-RevId: 373832649
--
d75819786ff5a06e1ed0c5c1e80b3b95ac49c83b by Evan Brown <ezb@google.com>:
Don't export adapted comparator functionality in key_comp().
PiperOrigin-RevId: 373651039
GitOrigin-RevId: 30af50146f07d7afdb196abf235f44ec44ea6409
Change-Id: I260480b0923cefeba81c543e2b7c34cacaa7d7c7
Diffstat (limited to 'absl/container/internal/raw_hash_set.h')
-rw-r--r-- | absl/container/internal/raw_hash_set.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index b23e0078..669785e6 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h @@ -628,7 +628,9 @@ class raw_hash_set { static Layout MakeLayout(size_t capacity) { assert(IsValidCapacity(capacity)); - return Layout(capacity + Group::kWidth + 1, capacity); + // The extra control bytes are for 1 sentinel byte followed by + // `Group::kWidth - 1` bytes that are cloned from the beginning. + return Layout(capacity + Group::kWidth, capacity); } using AllocTraits = absl::allocator_traits<allocator_type>; @@ -1782,8 +1784,8 @@ class raw_hash_set { growth_left() = CapacityToGrowth(capacity()) - size_; } - // Sets the control byte, and if `i < Group::kWidth`, set the cloned byte at - // the end too. + // Sets the control byte, and if `i < Group::kWidth - 1`, set the cloned byte + // at the end too. void set_ctrl(size_t i, ctrl_t h) { assert(i < capacity_); @@ -1794,8 +1796,8 @@ class raw_hash_set { } ctrl_[i] = h; - ctrl_[((i - Group::kWidth) & capacity_) + 1 + - ((Group::kWidth - 1) & capacity_)] = h; + constexpr size_t kClonedBytes = Group::kWidth - 1; + ctrl_[((i - kClonedBytes) & capacity_) + (kClonedBytes & capacity_)] = h; } size_t& growth_left() { return settings_.template get<0>(); } @@ -1814,7 +1816,7 @@ class raw_hash_set { // TODO(alkis): Investigate removing some of these fields: // - ctrl/slots can be derived from each other // - size can be moved into the slot array - ctrl_t* ctrl_ = EmptyGroup(); // [(capacity + 1) * ctrl_t] + ctrl_t* ctrl_ = EmptyGroup(); // [(capacity + Group::kWidth) * ctrl_t] slot_type* slots_ = nullptr; // [capacity * slot_type] size_t size_ = 0; // number of full slots size_t capacity_ = 0; // total number of slots |