Skip to content

Commit 39186f6

Browse files
authored
Merge pull request #23760 from JuliaLang/nl/select2
Use @views rather than checking index type in partialsort[perm]!()
2 parents d50eac6 + 9e4af4b commit 39186f6

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

base/sort.jl

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ issorted(itr;
8585
function partialsort!(v::AbstractVector, k::Union{Int,OrdinalRange}, o::Ordering)
8686
inds = indices(v, 1)
8787
sort!(v, first(inds), last(inds), PartialQuickSort(k), o)
88-
89-
if k isa Integer
90-
return v[k]
91-
else
92-
return view(v, k)
93-
end
88+
@views v[k]
9489
end
9590

9691
"""
@@ -712,11 +707,7 @@ function partialsortperm!(ix::AbstractVector{<:Integer}, v::AbstractVector,
712707
# do partial quicksort
713708
sort!(ix, PartialQuickSort(k), Perm(ord(lt, by, rev, order), v))
714709

715-
if k isa Integer
716-
return ix[k]
717-
else
718-
return view(ix, k)
719-
end
710+
@views ix[k]
720711
end
721712

722713
## sortperm: the permutation to sort an array ##

0 commit comments

Comments
 (0)