Skip to content

Commit

Permalink
Merge pull request #23760 from JuliaLang/nl/select2
Browse files Browse the repository at this point in the history
Use @views rather than checking index type in partialsort[perm]!()
  • Loading branch information
nalimilan authored Sep 20, 2017
2 parents d50eac6 + 9e4af4b commit 39186f6
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,7 @@ issorted(itr;
function partialsort!(v::AbstractVector, k::Union{Int,OrdinalRange}, o::Ordering)
inds = indices(v, 1)
sort!(v, first(inds), last(inds), PartialQuickSort(k), o)

if k isa Integer
return v[k]
else
return view(v, k)
end
@views v[k]
end

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

if k isa Integer
return ix[k]
else
return view(ix, k)
end
@views ix[k]
end

## sortperm: the permutation to sort an array ##
Expand Down

0 comments on commit 39186f6

Please sign in to comment.