authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-10-02 23:07:28-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-10-03 01:21:51-07:00
log95f4c1532aa4fe7f0ec8f733f7e79c85d2c09b52
tree2c82e3f14df0a18af2363898db4fd65ce7f80950
parentcf3572a66bb956eff319ebcb123784322e2553de

Treap: do not set key to undefined in `remove` to allow re-use of removed nodes


2 files changed, 0 insertions(+), 3 deletions(-)

lib/std/heap/general_purpose_allocator.zig-2
...@@ -913,8 +913,6 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {...@@ -913,8 +913,6 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
913 // save the node for destruction/insertion into in empty_buckets913 // save the node for destruction/insertion into in empty_buckets
914 var node = entry.node.?;914 var node = entry.node.?;
915 entry.set(null);915 entry.set(null);
916 // restore the node's key since Treap.remove sets it to undefined
917 node.key = bucket;
918 if (self.cur_buckets[bucket_index] == bucket) {916 if (self.cur_buckets[bucket_index] == bucket) {
919 self.cur_buckets[bucket_index] = null;917 self.cur_buckets[bucket_index] = null;
920 }918 }
lib/std/treap.zig-1
...@@ -225,7 +225,6 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {...@@ -225,7 +225,6 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
225 link.* = null;225 link.* = null;
226226
227 // clean up after ourselves227 // clean up after ourselves
228 node.key = undefined;
229 node.priority = 0;228 node.priority = 0;
230 node.parent = null;229 node.parent = null;
231 node.children = [_]?*Node{ null, null };230 node.children = [_]?*Node{ null, null };