From a102588a4ecde6face760201af3213108628cd34 Mon Sep 17 00:00:00 2001 From: K Pamnany Date: Fri, 16 Feb 2024 15:03:55 -0500 Subject: [PATCH] Use `Base._unsetindex!` in `pop!` and `popfirst!` for Deque So that popped elements are not rooted by the deque and can be GCed when they drop out of caller scope. --- src/deque.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/deque.jl b/src/deque.jl index 1ba54c13..d4bd0283 100644 --- a/src/deque.jl +++ b/src/deque.jl @@ -297,6 +297,7 @@ function Base.pop!(d::Deque{T}) where T @assert rear.back >= rear.front @inbounds x = rear.data[rear.back] + Base._unsetindex!(rear.data, rear.back) rear.back -= 1 if rear.back < rear.front if d.nblocks > 1 @@ -322,6 +323,7 @@ function Base.popfirst!(d::Deque{T}) where T @assert head.back >= head.front @inbounds x = head.data[head.front] + Base._unsetindex!(head.data, head.front) head.front += 1 if head.back < head.front if d.nblocks > 1