Implement `raw_hash_set::count()` in terms of `contains()`. This improves generated code only in non-opt mode (debug and hardened builds) by avoiding iterator comparison assertions and stack spills, saving ~40 bytes per call site. In optimized mode (`-c opt`), this is neutral as `find(key) == end()` and `contains(key)` compile to identical assembly. PiperOrigin-RevId: 1004966471
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index ecfcb5e..0b2d03d 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h
@@ -3444,7 +3444,7 @@ // s.count("abc"); template <class K = key_type> size_t count(const key_arg<K>& key) const { - return find(key) == end() ? 0 : 1; + return contains(key) ? 1 : 0; } // Issues CPU prefetch instructions for the memory needed to find or insert