Skip to content

Commit 3e2420e

Browse files
Lilith HafnerLilith Hafner
authored andcommitted
fixup for a975bcf
1 parent cb1ad9e commit 3e2420e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

base/sort.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -866,21 +866,24 @@ function _sort!(v::AbstractVector, a::RadixSort, o::DirectOrdering, kw)
866866
U = UIntMappable(eltype(v), o)
867867
# A large if-else chain to avoid type instabilities and dynamic dispatch
868868
if scratch !== nothing && checkbounds(Bool, scratch, lo:hi) # Fully preallocated and aligned scratch
869-
if radix_sort!(u, lo, hi, bits, reinterpret(U, scratch))
869+
t = reinterpret(U, scratch)
870+
if radix_sort!(u, lo, hi, bits, t)
870871
uint_unmap!(v, u, lo, hi, o, umn)
871872
else
872873
uint_unmap!(v, t, lo, hi, o, umn)
873874
end
874875
elseif scratch !== nothing && (applicable(resize!, scratch, len) || length(scratch) >= len) # Viable scratch
875876
length(scratch) >= len || resize!(scratch, len)
876877
t1 = axes(scratch, 1) isa OneTo ? scratch : view(scratch, firstindex(scratch):lastindex(scratch))
877-
if radix_sort!(view(u, lo:hi), 1, len, bits, reinterpret(U, t1))
878-
uint_unmap!(view(v, lo:hi), u, 1, len, o, umn)
878+
t = reinterpret(U, t1)
879+
if radix_sort!(view(u, lo:hi), 1, len, bits, t)
880+
uint_unmap!(view(v, lo:hi), view(u, lo:hi), 1, len, o, umn)
879881
else
880882
uint_unmap!(view(v, lo:hi), t, 1, len, o, umn)
881883
end
882884
else # No viable scratch
883-
if radix_sort!(u, lo, hi, bits, similar(u))
885+
t = similar(u)
886+
if radix_sort!(u, lo, hi, bits, t)
884887
uint_unmap!(v, u, lo, hi, o, umn)
885888
else
886889
uint_unmap!(v, t, lo, hi, o, umn)

0 commit comments

Comments
 (0)