From cae7b88388400a71428445490aceab755f9eccdb Mon Sep 17 00:00:00 2001 From: Evan Haas Date: Mon, 4 Dec 2023 11:07:47 -0800 Subject: [PATCH] Hideset: use identifer loc instead of string to compute intersections --- src/aro/Hideset.zig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/aro/Hideset.zig b/src/aro/Hideset.zig index b91cd5c1..e570b87e 100644 --- a/src/aro/Hideset.zig +++ b/src/aro/Hideset.zig @@ -54,7 +54,7 @@ const Index = enum(u32) { map: std.AutoHashMapUnmanaged(Identifier, Index) = .{}, /// Used for computing intersection of two lists; stored here so that allocations can be retained /// until hideset is deinit'ed -intersection_map: std.StringHashMapUnmanaged(void) = .{}, +intersection_map: std.AutoHashMapUnmanaged(Identifier, void) = .{}, linked_list: Item.List = .{}, comp: *const Compilation, @@ -164,15 +164,13 @@ pub fn intersection(self: *Hideset, a: Index, b: Index) !Index { var it = self.iterator(a); var a_len: usize = 0; while (it.next()) |identifier| : (a_len += 1) { - const str = identifier.slice(self.comp); - try self.intersection_map.put(self.comp.gpa, str, {}); + try self.intersection_map.put(self.comp.gpa, identifier, {}); } try self.ensureUnusedCapacity(@min(a_len, self.len(b))); it = self.iterator(b); while (it.next()) |identifier| { - const str = identifier.slice(self.comp); - if (self.intersection_map.contains(str)) { + if (self.intersection_map.contains(identifier)) { const new_idx = self.createNodeAssumeCapacity(identifier); if (head == .sentinel) { head = new_idx;