Skip to content

Commit 0a17953

Browse files
authored
Fix _addcounts_radix_sort for empty input array (#706)
1 parent ef208fe commit 0a17953

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/counts.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ const BaseRadixSortSafeTypes = Union{Int8, Int16, Int32, Int64, Int128,
336336
radixsort_safe(::Type{T}) where T = T<:BaseRadixSortSafeTypes
337337

338338
function _addcounts_radix_sort_loop!(cm::Dict{T}, sx::AbstractArray{T}) where T
339+
isempty(sx) && return cm
339340
last_sx = sx[1]
340341
tmpcount = get(cm, last_sx, 0) + 1
341342

test/counts.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ cm_any_itr = countmap((i for i in xx))
108108
@test cm_any_itr isa Dict{Any,Int} # no knowledge about type
109109
@test cm_missing == cm
110110

111+
# with empty array
112+
@test countmap(Int[]) == Dict{Int, Int}()
113+
111114
# testing the radixsort-based addcounts
112115
xx = repeat([6, 1, 3, 1], outer=100_000)
113116
cm = Dict{Int, Int}()

0 commit comments

Comments
 (0)