From c8c54f2067b384237ce991278375bb3c24eddc6d Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Mon, 31 Aug 2026 14:55:43 +0800 Subject: [PATCH] minor: remove potentially wasteful id dupe on removeId We currently unconditionally dupe the remove_ids key. But it _could_ already exist in the map. Swapping the unconditional put with a getOrPut. --- src/browser/Frame.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/browser/Frame.zig b/src/browser/Frame.zig index 2e664e57d..0d4256092 100644 --- a/src/browser/Frame.zig +++ b/src/browser/Frame.zig @@ -2180,10 +2180,14 @@ pub fn removeElementId(self: *Frame, element: *Element, id: []const u8) void { pub fn removeElementIdWithMaps(self: *Frame, id_maps: ElementIdMaps, id: []const u8) void { if (id_maps.lookup.remove(id)) { - const owned_id = self.dupeString(id) catch return; - id_maps.removed_ids.put(self.arena, owned_id, {}) catch |err| { + const gop = id_maps.removed_ids.getOrPut(self.arena, id) catch |err| { log.warn(.frame, "removeElementIdWithMaps", .{ .err = err }); + return; }; + if (gop.found_existing == false) { + gop.key_ptr.* = self.dupeString(id) catch return; + gop.value_ptr.* = {}; + } } }