Skip to content

Commit

Permalink
Reduce build-time calls to broadcasting machinery
Browse files Browse the repository at this point in the history
The main one left is in concatenation, in a line

    inds[i] = offsets[i] .+ cat_indices(x, i)
  • Loading branch information
timholy committed Jan 7, 2018
1 parent ec8064c commit c0db74c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
7 changes: 5 additions & 2 deletions base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,12 @@ issorted(itr;
function partialsort!(v::AbstractVector, k::Union{Int,OrdinalRange}, o::Ordering)
inds = axes(v, 1)
sort!(v, first(inds), last(inds), PartialQuickSort(k), o)
@views v[k]
maybeview(v, k)
end

maybeview(v, k) = view(v, k)
maybeview(v, k::Integer) = v[k]

"""
partialsort!(v, k, [by=<transform>,] [lt=<comparison>,] [rev=false])
Expand Down Expand Up @@ -707,7 +710,7 @@ function partialsortperm!(ix::AbstractVector{<:Integer}, v::AbstractVector,
# do partial quicksort
sort!(ix, PartialQuickSort(k), Perm(ord(lt, by, rev, order), v))

@views ix[k]
maybeview(ix, k)
end

## sortperm: the permutation to sort an array ##
Expand Down
32 changes: 16 additions & 16 deletions base/stat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,22 @@ operm(st::StatStruct) = UInt8((filemode(st) ) & 0x7)
# mode predicate methods for file names

for f in Symbol[
:ispath
:isfifo
:ischardev
:isdir
:isblockdev
:isfile
:issocket
:issetuid
:issetgid
:issticky
:uperm
:gperm
:operm
:filemode
:filesize
:mtime
:ispath,
:isfifo,
:ischardev,
:isdir,
:isblockdev,
:isfile,
:issocket,
:issetuid,
:issetgid,
:issticky,
:uperm,
:gperm,
:operm,
:filemode,
:filesize,
:mtime,
:ctime
]
@eval ($f)(path...) = ($f)(stat(path...))
Expand Down

0 comments on commit c0db74c

Please sign in to comment.