Skip to content

Commit 5657e5f

Browse files
Lilith HafnerLilith Hafner
authored andcommitted
implement Oscar's suggestion to speed up heuristic computation
1 parent 5c18e25 commit 5657e5f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

base/sort.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,9 +1232,10 @@ function _sort!(v::AbstractVector, a::BracketedSort, o::Ordering, kw)
12321232
ln < 260 && return _sort!(v, a.get_next(a.target), o, kw)
12331233

12341234
target = a.target
1235-
k2 = round(Int, ln^(2/3))
1235+
k = cbrt(ln)
1236+
k2 = round(Int, k^2)
12361237
k2ln = k2/ln
1237-
offset = .7k2^0.575 # TODO for further optimization: tune this
1238+
offset = .15k2*top_set_bit(k2) # TODO for further optimization: tune this
12381239
lo_signpost_i, hi_signpost_i =
12391240
(floor(Int, (tar - lo) * k2ln + lo + off) for (tar, off) in
12401241
((minimum(target), -offset), (maximum(target), offset)))

0 commit comments

Comments
 (0)