Skip to content

Commit

Permalink
Rework casting in raw_hash_set's IsFull().
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 636218177
Change-Id: I9f58ccbb468fcc0c44ef12162415f7b721a745bf
  • Loading branch information
grebe authored and copybara-github committed May 22, 2024
1 parent ac810be commit 1a31b81
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion absl/container/internal/raw_hash_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down

0 comments on commit 1a31b81

Please sign in to comment.