Skip to content

Commit 17f05b5

Browse files
authored
[NFC] rename where -> counts (#43052)
Because `where` is a keyword that often has syntax highlighting, and `counts` is more descriptive.
1 parent ec3ec02 commit 17f05b5

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

base/sort.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -727,14 +727,14 @@ end
727727
function sort_int_range!(x::AbstractVector{<:Integer}, rangelen, minval, maybereverse)
728728
offs = 1 - minval
729729

730-
where = fill(0, rangelen)
730+
counts = fill(0, rangelen)
731731
@inbounds for i = eachindex(x)
732-
where[x[i] + offs] += 1
732+
counts[x[i] + offs] += 1
733733
end
734734

735735
idx = firstindex(x)
736736
@inbounds for i = maybereverse(1:rangelen)
737-
lastidx = idx + where[i] - 1
737+
lastidx = idx + counts[i] - 1
738738
val = i-offs
739739
for j = idx:lastidx
740740
x[j] = val
@@ -975,22 +975,22 @@ function sortperm_int_range(x::Vector{<:Integer}, rangelen, minval)
975975
offs = 1 - minval
976976
n = length(x)
977977

978-
where = fill(0, rangelen+1)
979-
where[1] = 1
978+
counts = fill(0, rangelen+1)
979+
counts[1] = 1
980980
@inbounds for i = 1:n
981-
where[x[i] + offs + 1] += 1
981+
counts[x[i] + offs + 1] += 1
982982
end
983983

984-
#cumsum!(where, where)
985-
@inbounds for i = 2:length(where)
986-
where[i] += where[i-1]
984+
#cumsum!(counts, counts)
985+
@inbounds for i = 2:length(counts)
986+
counts[i] += counts[i-1]
987987
end
988988

989989
P = Vector{Int}(undef, n)
990990
@inbounds for i = 1:n
991991
label = x[i] + offs
992-
P[where[label]] = i
993-
where[label] += 1
992+
P[counts[label]] = i
993+
counts[label] += 1
994994
end
995995

996996
return P

0 commit comments

Comments
 (0)