Explicitly instantiate common `raw_hash_set` backing array functions. Add explicit template instantiations for `AllocateBackingArray` and `DeallocateBackingArray` in `raw_hash_set.cc` for the `std::allocator<char>` and `alignof(size_t)` case. Add corresponding `extern template` declarations in `raw_hash_set.h`. This reduces compile times and linker input size by ensuring these common instantiations are only generated once. PiperOrigin-RevId: 828501019 Change-Id: I2927e756f0cf8238d6455c6eee4473fff790435f
diff --git a/absl/container/internal/raw_hash_set.cc b/absl/container/internal/raw_hash_set.cc index 09076b4..ea3a3bf 100644 --- a/absl/container/internal/raw_hash_set.cc +++ b/absl/container/internal/raw_hash_set.cc
@@ -2067,6 +2067,14 @@ static_assert(MaxSooSlotSize() == 16); #endif +template void* AllocateBackingArray<BackingArrayAlignment(alignof(size_t)), + std::allocator<char>>(void* alloc, + size_t n); +template void DeallocateBackingArray<BackingArrayAlignment(alignof(size_t)), + std::allocator<char>>( + void* alloc, size_t capacity, ctrl_t* ctrl, size_t slot_size, + size_t slot_align, bool had_infoz); + } // namespace container_internal ABSL_NAMESPACE_END } // namespace absl
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index 147a756..faa7880 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h
@@ -3703,6 +3703,14 @@ bool); #endif +extern template void* AllocateBackingArray< + BackingArrayAlignment(alignof(size_t)), std::allocator<char>>(void* alloc, + size_t n); +extern template void DeallocateBackingArray< + BackingArrayAlignment(alignof(size_t)), std::allocator<char>>( + void* alloc, size_t capacity, ctrl_t* ctrl, size_t slot_size, + size_t slot_align, bool had_infoz); + } // namespace container_internal ABSL_NAMESPACE_END } // namespace absl