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 {
913913 // save the node for destruction/insertion into in empty_buckets
914914 var node = entry.node.?;
915915 entry.set(null);
916 // restore the node's key since Treap.remove sets it to undefined
917 node.key = bucket;
918916 if (self.cur_buckets[bucket_index] == bucket) {
919917 self.cur_buckets[bucket_index] = null;
920918 }
lib/std/treap.zig-1
......@@ -225,7 +225,6 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
225225 link.* = null;
226226
227227 // clean up after ourselves
228 node.key = undefined;
229228 node.priority = 0;
230229 node.parent = null;
231230 node.children = [_]?*Node{ null, null };