summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/zisp/gc/IstrSet.zig45
1 files changed, 0 insertions, 45 deletions
diff --git a/src/zisp/gc/IstrSet.zig b/src/zisp/gc/IstrSet.zig
index 6e5b95c..b22d57b 100644
--- a/src/zisp/gc/IstrSet.zig
+++ b/src/zisp/gc/IstrSet.zig
@@ -22,8 +22,6 @@ buckets: []Bucket = undefined,
used_buckets: usize = 0,
used_threshold: usize = undefined,
-const test_stdlib_impl = false;
-
const default_bcount = 512;
pub fn init(alloc: Alloc) !Set {
@@ -31,10 +29,6 @@ pub fn init(alloc: Alloc) !Set {
}
pub fn initCustom(alloc: Alloc, bcount: usize) !Set {
- if (test_stdlib_impl) {
- istr_hash_map = .init(alloc);
- return Set{ .alloc = alloc };
- }
std.debug.assert(@popCount(bcount) == 1); // Must be power of 2.
var self = Set{ .alloc = alloc };
try self.allocBuckets(bcount);
@@ -55,10 +49,6 @@ pub fn deinit(self: *Set) void {
pub fn add(self: *Set, s: []const u8) !IstrPtr {
std.debug.assert(s.len < 256);
- if (test_stdlib_impl) {
- return addStdlib(self.alloc, s);
- }
-
if (self.used_buckets > self.used_threshold) {
try self.resize();
}
@@ -142,38 +132,3 @@ fn resize(self: *Set) !void {
if (idx == idx_start) break;
}
}
-
-// Using stdlib, to compare
-
-const Map = std.hash_map.StringHashMap(IstrPtr);
-const str_context = std.hash_map.StringContext{};
-var istr_hash_map: Map = undefined;
-
-pub fn addStdlib(alloc: Alloc, str: []const u8) !IstrPtr {
- const gop = istr_hash_map.getOrPutAdapted(
- str,
- str_context,
- ) catch @panic("OOM");
- if (gop.found_existing) {
- return gop.value_ptr.*;
- }
-
- std.debug.assert(str.len <= std.math.maxInt(u48));
-
- const header: IstrHead = .{ .len = @intCast(str.len) };
-
- const h_align: std.mem.Alignment = @enumFromInt(@alignOf(IstrPtr));
- const h_size = @sizeOf(IstrHead);
- const size = str.len + h_size;
-
- const mem = alloc.alignedAlloc(u8, h_align, size) catch @panic("OOM");
-
- const h_bytes: [h_size]u8 = @bitCast(header);
- @memcpy(mem[0..h_size], &h_bytes);
- @memcpy(mem[h_size..size], str);
-
- gop.key_ptr.* = alloc.dupe(u8, str) catch @panic("OOM");
- gop.value_ptr.* = @ptrCast(mem.ptr);
-
- return @ptrCast(mem.ptr);
-}