diff options
author | Paul Rigge <rigge@google.com> | 2024-05-22 10:39:28 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-05-22 10:40:26 -0700 |
commit | 1a31b81c0a467c1c8e229b9fc172a4eb0db5bd85 (patch) | |
tree | 4b5fdde2eae9c31d77309997093b50212681ef68 /absl | |
parent | ac810bee5a0477ff593205e167f09c1e0bd9a226 (diff) |
Rework casting in raw_hash_set's IsFull().
PiperOrigin-RevId: 636218177
Change-Id: I9f58ccbb468fcc0c44ef12162415f7b721a745bf
Diffstat (limited to 'absl')
-rw-r--r-- | absl/container/internal/raw_hash_set.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index a64133a7..1f677a4e 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h @@ -623,7 +623,12 @@ inline h2_t H2(size_t hash) { return hash & 0x7F; } // Helpers for checking the state of a control byte. inline bool IsEmpty(ctrl_t c) { return c == ctrl_t::kEmpty; } -inline bool IsFull(ctrl_t c) { return c >= static_cast<ctrl_t>(0); } +inline bool IsFull(ctrl_t c) { + // Cast `c` to the underlying type instead of casting `0` to `ctrl_t` as `0` + // is not a value in the enum. Both ways are equivalent, but this way makes + // linters happier. + return static_cast<std::underlying_type_t<ctrl_t>>(c) >= 0; +} inline bool IsDeleted(ctrl_t c) { return c == ctrl_t::kDeleted; } inline bool IsEmptyOrDeleted(ctrl_t c) { return c < ctrl_t::kSentinel; } |