Skip to content

Commit

Permalink
Treap: do not set key to undefined in remove to allow re-use of rem…
Browse files Browse the repository at this point in the history
…oved nodes
  • Loading branch information
squeek502 committed Oct 3, 2023
1 parent 40409c8 commit 42ae395
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 3 deletions.
2 changes: 0 additions & 2 deletions lib/std/heap/general_purpose_allocator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,6 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
// save the node for destruction/insertion into in empty_buckets
var node = entry.node.?;
entry.set(null);
// restore the node's key since Treap.remove sets it to undefined
node.key = bucket;
if (self.cur_buckets[bucket_index] == bucket) {
self.cur_buckets[bucket_index] = null;
}
Expand Down
1 change: 0 additions & 1 deletion lib/std/treap.zig
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
link.* = null;

// clean up after ourselves
node.key = undefined;
node.priority = 0;
node.parent = null;
node.children = [_]?*Node{ null, null };
Expand Down

0 comments on commit 42ae395

Please sign in to comment.