@@ -144,15 +144,12 @@ class HashSet {
144144 uint32_t *old_hashes = hashes;
145145 uint32_t *old_key_to_hash = key_to_hash;
146146
147- hashes = reinterpret_cast <uint32_t *>(Memory::alloc_static (sizeof (uint32_t ) * capacity));
147+ static_assert (EMPTY_HASH == 0 , " Assuming EMPTY_HASH = 0 for alloc_static_zeroed call" );
148+ hashes = reinterpret_cast <uint32_t *>(Memory::alloc_static_zeroed (sizeof (uint32_t ) * capacity));
148149 keys = reinterpret_cast <TKey *>(Memory::realloc_static (keys, sizeof (TKey) * capacity));
149150 key_to_hash = reinterpret_cast <uint32_t *>(Memory::alloc_static (sizeof (uint32_t ) * capacity));
150151 hash_to_key = reinterpret_cast <uint32_t *>(Memory::realloc_static (hash_to_key, sizeof (uint32_t ) * capacity));
151152
152- for (uint32_t i = 0 ; i < capacity; i++) {
153- hashes[i] = EMPTY_HASH;
154- }
155-
156153 for (uint32_t i = 0 ; i < num_elements; i++) {
157154 uint32_t h = old_hashes[old_key_to_hash[i]];
158155 _insert_with_hash (h, i);
@@ -167,14 +164,11 @@ class HashSet {
167164 if (unlikely (keys == nullptr )) {
168165 // Allocate on demand to save memory.
169166
170- hashes = reinterpret_cast <uint32_t *>(Memory::alloc_static (sizeof (uint32_t ) * capacity));
167+ static_assert (EMPTY_HASH == 0 , " Assuming EMPTY_HASH = 0 for alloc_static_zeroed call" );
168+ hashes = reinterpret_cast <uint32_t *>(Memory::alloc_static_zeroed (sizeof (uint32_t ) * capacity));
171169 keys = reinterpret_cast <TKey *>(Memory::alloc_static (sizeof (TKey) * capacity));
172170 key_to_hash = reinterpret_cast <uint32_t *>(Memory::alloc_static (sizeof (uint32_t ) * capacity));
173171 hash_to_key = reinterpret_cast <uint32_t *>(Memory::alloc_static (sizeof (uint32_t ) * capacity));
174-
175- for (uint32_t i = 0 ; i < capacity; i++) {
176- hashes[i] = EMPTY_HASH;
177- }
178172 }
179173
180174 uint32_t pos = 0 ;
0 commit comments