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

Fixups for #47383 (fixes runbenchmarks("sort")) #47822

Merged
merged 5 commits into from
Dec 13, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix overflow in countsort
Lilith Hafner authored and Lilith Hafner committed Dec 7, 2022
commit 2ea650897fb53a20754c14ef9a9952e9fe0a157d
2 changes: 1 addition & 1 deletion base/sort.jl
Original file line number Diff line number Diff line change
@@ -830,7 +830,7 @@ maybe_reverse(o::ForwardOrdering, x) = x
maybe_reverse(o::ReverseOrdering, x) = reverse(x)
function _sort!(v::AbstractVector{<:Integer}, ::CountingSort, o::DirectOrdering, kw)
@getkw lo hi mn mx scratch
range = o === Reverse ? mn-mx : mx-mn
range = maybe_unsigned(o === Reverse ? mn-mx : mx-mn)
offs = 1 - (o === Reverse ? mx : mn)

counts = fill(0, range+1) # TODO use scratch (but be aware of type stability)