aboutsummaryrefslogtreecommitdiff
path: root/src/hash_map.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/hash_map.zig')
-rw-r--r--src/hash_map.zig18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/hash_map.zig b/src/hash_map.zig
index 853ad39be..431ea3611 100644
--- a/src/hash_map.zig
+++ b/src/hash_map.zig
@@ -410,7 +410,7 @@ pub fn HashMapUnmanaged(
index: Size = 0,
pub fn next(it: *Iterator) ?*Entry {
- assert(it.index <= it.hm.capacity());
+ if (std.builtin.mode != .ReleaseFast) assert(it.index <= it.hm.capacity());
if (it.hm.size == 0) return null;
const cap = it.hm.capacity();
@@ -524,7 +524,7 @@ pub fn HashMapUnmanaged(
/// Insert an entry in the map. Assumes it is not already present.
pub fn putNoClobber(self: *Self, allocator: *Allocator, key: K, value: V) !void {
- assert(!self.contains(key));
+ if (std.builtin.mode != .ReleaseFast) assert(!self.contains(key));
try self.growIfNeeded(allocator, 1);
self.putAssumeCapacityNoClobber(key, value);
@@ -541,7 +541,7 @@ pub fn HashMapUnmanaged(
/// Insert an entry in the map. Assumes it is not already present,
/// and that no allocation is needed.
pub fn putAssumeCapacityNoClobber(self: *Self, key: K, value: V) void {
- assert(!self.contains(key));
+ if (std.builtin.mode != .ReleaseFast) assert(!self.contains(key));
const hash = hashFn(key);
putAssumeCapacityNoClobberWithHash(self, key, hash, value);
@@ -560,7 +560,7 @@ pub fn HashMapUnmanaged(
}
if (!metadata[0].isTombstone()) {
- assert(self.available > 0);
+ if (std.builtin.mode != .ReleaseFast) assert(self.available > 0);
self.available -= 1;
}
@@ -795,7 +795,7 @@ pub fn HashMapUnmanaged(
/// Asserts there is an `Entry` with matching key, deletes it from the hash map,
/// and discards it.
pub fn removeAssertDiscard(self: *Self, key: K) void {
- assert(self.contains(key));
+ if (std.builtin.mode != .ReleaseFast) assert(self.contains(key));
const hash = hashFn(key);
const mask = self.capacity() - 1;
@@ -828,7 +828,7 @@ pub fn HashMapUnmanaged(
// what has to stay under the max_load_percentage of capacity.
fn load(self: *const Self) Size {
const max_load = (self.capacity() * max_load_percentage) / 100;
- assert(max_load >= self.available);
+ if (std.builtin.mode != .ReleaseFast) assert(max_load >= self.available);
return @truncate(Size, max_load - self.available);
}
@@ -865,8 +865,8 @@ pub fn HashMapUnmanaged(
fn grow(self: *Self, allocator: *Allocator, new_capacity: Size) !void {
const new_cap = std.math.max(new_capacity, minimal_capacity);
- assert(new_cap > self.capacity());
- assert(std.math.isPowerOfTwo(new_cap));
+ if (std.builtin.mode != .ReleaseFast) assert(new_cap > self.capacity());
+ if (std.builtin.mode != .ReleaseFast) assert(std.math.isPowerOfTwo(new_cap));
var map = Self{};
defer map.deinit(allocator);
@@ -907,7 +907,7 @@ pub fn HashMapUnmanaged(
const metadata = ptr + @sizeOf(Header);
var entry_ptr = ptr + meta_size;
entry_ptr = (entry_ptr + alignment) & ~@as(usize, alignment);
- assert(entry_ptr + @as(usize, new_capacity) * @sizeOf(Entry) <= ptr + total_size);
+ if (std.builtin.mode != .ReleaseFast) assert(entry_ptr + @as(usize, new_capacity) * @sizeOf(Entry) <= ptr + total_size);
const hdr = @intToPtr(*Header, ptr);
hdr.entries = @intToPtr([*]Entry, entry_ptr);