Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use @views rather than checking index type in partialsort[perm]!() #23760

Merged
merged 1 commit into from
Sep 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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