mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-10-04 02:14:54 -04:00
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:
1 file changed
+6
-2
@@ -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.* = {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user