Remove internal invariant assertions that are either redundant and/or being done right after the branch checking very similar condition.

Also moved "full table" assertion to probe_seq.

That is mean to optimize compilation time in debug mode.

PiperOrigin-RevId: 993102710
Change-Id: Ief0b8d798db031b9f6e0ae9862ece67d67e5ad5f
diff --git a/absl/container/internal/raw_hash_set.cc b/absl/container/internal/raw_hash_set.cc
index 810bc25..ab3fe8a 100644
--- a/absl/container/internal/raw_hash_set.cc
+++ b/absl/container/internal/raw_hash_set.cc
@@ -175,7 +175,6 @@
       return mask;
     }
     seq.next();
-    ABSL_SWISSTABLE_ASSERT(seq.index() <= capacity && "full table!");
   }
 }
 
@@ -1088,7 +1087,6 @@
   auto seq = probe(ProbeCapacity{cap}, hash);
   while (((target - seq.offset()) & cap) >= Group::kWidth) {
     seq.next();
-    ABSL_SWISSTABLE_ASSERT(seq.index() < common.capacity());
   }
   common.infoz().RecordInsertMiss(hash, seq.index());
 }
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h
index d6b7496..fc7cc40 100644
--- a/absl/container/internal/raw_hash_set.h
+++ b/absl/container/internal/raw_hash_set.h
@@ -1806,6 +1806,7 @@
   size_t offset(size_t i) const { return (offset_ + i) & capacity_; }
 
   void next() {
+    ABSL_SWISSTABLE_ASSERT(next_index_ <= capacity_ && "full table!");
     offset_ += next_index_;
     offset_ &= capacity_;
     next_index_ += Width;
@@ -3462,20 +3463,18 @@
   // SOO functionality.
   template <class K = key_type>
   ABSL_ATTRIBUTE_ALWAYS_INLINE iterator find_small(const key_arg<K>& key) {
-    ABSL_SWISSTABLE_ASSERT(is_small());
     return empty() || !equal_to(key, single_slot()) ? end() : single_iterator();
   }
 
   template <class K = key_type>
   iterator find_large(const key_arg<K>& key) {
-    ABSL_SWISSTABLE_ASSERT(!is_small());
     const size_t cap = common().capacity();
     ABSL_ASSUME(cap > kMaxSmallCapacity);
     const size_t hash = hash_of(key);
     auto seq = probe(ProbeCapacity{cap}, hash);
     const h2_t h2 = H2(hash);
     ctrl_t* ctrl = control();
-    slot_type* slot_array = to_slot(common().slot_array(cap));
+    slot_type* slot_array = this->slot_array(cap);
     while (true) {
       // Loading the group before slot prefetch decreases critical path latency.
       Group g{ctrl + seq.offset()};
@@ -3489,7 +3488,6 @@
       }
       if (ABSL_PREDICT_TRUE(g.MaskEmpty())) return end();
       seq.next();
-      ABSL_SWISSTABLE_ASSERT(seq.index() <= cap && "full table!");
     }
   }
 
@@ -3716,7 +3714,6 @@
   template <class K>
   ABSL_ATTRIBUTE_ALWAYS_INLINE std::pair<slot_type*, bool>
   find_or_prepare_insert_soo(const K& key) {
-    ABSL_SWISSTABLE_ASSERT(is_soo());
     bool force_sampling;
     slot_type* slot = single_slot();
     if (empty()) {
@@ -3730,7 +3727,6 @@
     } else {
       force_sampling = false;
     }
-    ABSL_SWISSTABLE_ASSERT(capacity() == 1);
     constexpr bool kUseMemcpy =
         PolicyTraits::transfer_uses_memcpy() && SooEnabled();
     slot = to_slot(
@@ -3747,7 +3743,6 @@
   template <class K>
   ABSL_ATTRIBUTE_ALWAYS_INLINE std::pair<slot_type*, bool>
   find_or_prepare_insert_small(const K& key) {
-    ABSL_SWISSTABLE_ASSERT(is_small());
     if constexpr (SooEnabled()) {
       return find_or_prepare_insert_soo(key);
     }
@@ -3764,15 +3759,13 @@
 
   template <class K>
   std::pair<slot_type*, bool> find_or_prepare_insert_large(const K& key) {
-    ABSL_SWISSTABLE_ASSERT(!is_soo());
     prefetch_heap_block();
     const size_t cap = capacity();
-    ABSL_ASSUME(cap > kMaxSmallCapacity);
     const size_t hash = hash_of(key);
     auto seq = probe(ProbeCapacity{cap}, hash);
     const h2_t h2 = H2(hash);
     const ctrl_t* ctrl = control();
-    slot_type* slot_array = to_slot(common().slot_array(cap));
+    slot_type* slot_array = this->slot_array(cap);
     while (true) {
       // Loading the group before slot prefetch decreases critical path latency.
       Group g{ctrl + seq.offset()};
@@ -3800,7 +3793,6 @@
         return {to_slot(slot), true};
       }
       seq.next();
-      ABSL_SWISSTABLE_ASSERT(seq.index() <= capacity() && "full table!");
     }
   }
 
@@ -3933,7 +3925,6 @@
     return common().control();
   }
   slot_type* slot_array(size_t capacity) const {
-    ABSL_SWISSTABLE_ASSERT(!is_soo());
     return static_cast<slot_type*>(common().slot_array(capacity));
   }
   slot_type* soo_slot() {
diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc
index 2ae8023..43ac251 100644
--- a/absl/container/internal/raw_hash_set_test.cc
+++ b/absl/container/internal/raw_hash_set_test.cc
@@ -723,15 +723,16 @@
   size_t capacity = 127;
   probe_seq<16> seq(ProbeCapacity{capacity}, /*hash=*/0);
   auto gen = [&]() {
-    size_t res = seq.offset();
     seq.next();
-    return res;
+    return seq.offset();
   };
   std::vector<size_t> offsets(8);
-  std::generate_n(offsets.begin(), 8, gen);
+  offsets[0] = seq.offset();
+  std::generate_n(offsets.begin() + 1, 7, gen);
   EXPECT_THAT(offsets, ElementsAre(0, 16, 48, 96, 32, 112, 80, 64));
   seq = probe_seq<16>(ProbeCapacity{capacity}, /*hash=*/128);
-  std::generate_n(offsets.begin(), 8, gen);
+  offsets[0] = seq.offset();
+  std::generate_n(offsets.begin() + 1, 7, gen);
   EXPECT_THAT(offsets, ElementsAre(0, 16, 48, 96, 32, 112, 80, 64));
 }