Skip to content

Commit

Permalink
improve inferrability of list_deletefirst! (JuliaLang#38236)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Dec 1, 2020
1 parent 8c35003 commit a69ecaa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions base/linked_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function popfirst!(q::InvasiveLinkedList{T}) where {T}
return val
end

# this function assumes `val` is found in `q`
function list_deletefirst!(q::InvasiveLinkedList{T}, val::T) where T
val.queue === q || return
head = q.head::T
Expand All @@ -97,10 +98,10 @@ function list_deletefirst!(q::InvasiveLinkedList{T}, val::T) where T
q.head = val.next::T
end
else
head_next = head.next
head_next = head.next::T
while head_next !== val
head = head_next
head_next = head.next::Union{T, Nothing}
head_next = head.next::T
end
if q.tail::T === val
head.next = nothing
Expand Down

0 comments on commit a69ecaa

Please sign in to comment.