Skip to content

Commit

Permalink
Use @views rather than checking index type in partialsort[perm]!()
Browse files Browse the repository at this point in the history
It makes the code simpler.
  • Loading branch information
nalimilan committed Sep 18, 2017
1 parent d668a95 commit 9e4af4b
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 9e4af4b

Please sign in to comment.