Skip to content

Commit

Permalink
improve allunique's type stability (#56161)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored Oct 15, 2024
1 parent 0af99e6 commit fe82988
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,8 @@ function allunique(A::StridedArray)
if length(A) < 32
_indexed_allunique(A)
elseif OrderStyle(eltype(A)) === Ordered()
a1, rest1 = Iterators.peel(A)
a2, rest = Iterators.peel(rest1)
a1, rest1 = Iterators.peel(A)::Tuple{Any,Any}
a2, rest = Iterators.peel(rest1)::Tuple{Any,Any}
if !isequal(a1, a2)
compare = isless(a1, a2) ? isless : (a,b) -> isless(b,a)
for a in rest
Expand Down
1 change: 1 addition & 0 deletions test/sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ end
@test !allunique((NaN, NaN))
# Known length 1, need not evaluate:
@test allunique(error(x) for x in [1])
# @test_opt allunique(Int[])
end

@testset "allunique(f, xs)" begin
Expand Down

0 comments on commit fe82988

Please sign in to comment.