Skip to content

Commit 18b5b69

Browse files
committed
add @inbounds to topk
1 parent 41a5d23 commit 18b5b69

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/stat/non_hp_stat.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ TOPK_ISLESS(::Missing, y) = true
366366
TOPK_ISLESS(x, ::Missing) = true
367367
TOPK_ISLESS(::Missing, ::Missing) = false
368368

369-
function insert_fixed_sorted!(x, item, ord)
369+
Base.@propagate_inbounds function insert_fixed_sorted!(x, item, ord)
370370
if ord(item, x[end])
371371
x[end] = item
372372
else
@@ -383,7 +383,7 @@ function insert_fixed_sorted!(x, item, ord)
383383
end
384384
end
385385
# TODO we do not need x, this is just easier to implement, later we may fix this
386-
function insert_fixed_sorted_perm!(perm, x, idx, item, ord)
386+
Base.@propagate_inbounds function insert_fixed_sorted_perm!(perm, x, idx, item, ord)
387387
if ord(item, x[end])
388388
x[end] = item
389389
perm[end] = idx
@@ -403,7 +403,7 @@ function insert_fixed_sorted_perm!(perm, x, idx, item, ord)
403403
end
404404

405405

406-
function k_largest(x::AbstractVector{T}, k::Int) where {T}
406+
Base.@propagate_inbounds function k_largest(x::AbstractVector{T}, k::Int) where {T}
407407
k < 1 && throw(ArgumentError("k must be greater than 1"))
408408
k == 1 && return [maximum(identity, x)]
409409
all(ismissing, x) && return [missing]
@@ -423,7 +423,7 @@ function k_largest(x::AbstractVector{T}, k::Int) where {T}
423423
end
424424
end
425425

426-
function k_smallest(x::AbstractVector{T}, k::Int) where {T}
426+
Base.@propagate_inbounds function k_smallest(x::AbstractVector{T}, k::Int) where {T}
427427
k < 1 && throw(ArgumentError("k must be greater than 1"))
428428
k == 1 && return [minimum(identity, x)]
429429
all(ismissing, x) && return [missing]
@@ -446,7 +446,7 @@ end
446446

447447
# ktop permutation
448448

449-
function k_largest_perm(x::AbstractVector{T}, k::Int) where {T}
449+
Base.@propagate_inbounds function k_largest_perm(x::AbstractVector{T}, k::Int) where {T}
450450
k < 1 && throw(ArgumentError("k must be greater than 1"))
451451
k == 1 && return [maximum(identity, x)], [argmax(x)]
452452
all(ismissing, x) && return [missing], [missing]
@@ -467,7 +467,7 @@ function k_largest_perm(x::AbstractVector{T}, k::Int) where {T}
467467
end
468468
end
469469

470-
function k_smallest_perm(x::AbstractVector{T}, k::Int) where {T}
470+
Base.@propagate_inbounds function k_smallest_perm(x::AbstractVector{T}, k::Int) where {T}
471471
k < 1 && throw(ArgumentError("k must be greater than 1"))
472472
k == 1 && return [minimum(identity, x)], [argmin(x)]
473473
all(ismissing, x) && return [missing], [missing]

0 commit comments

Comments
 (0)