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.
This commit is contained in:
Karl Seguin committed 2026-08-31 14:55:43 +08:00
1 parent fad4b97079
commit c8c54f2067
1 file changed
+6 -2
+6 -2
View File
@@ -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.* = {};
}
}
}