Skip to content

Commit d5e0e37

Browse files
committed
use BitSet in count_unique
1 parent ead687e commit d5e0e37

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/connectivity.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function count_unique(label::Vector{T}) where {T}
197197
# effectively does `length(Set(label))` but faster, since `Set(label)` sizehints
198198
# aggressively and assumes that most elements of `label` will be unique, which very
199199
# rarely will be the case for caller `count_connected_components!`
200-
seen = Set{T}()
200+
seen = T === Int ? BitSet() : Set{T}() # if `T=Int`, we can use faster BitSet
201201
for l in label
202202
# faster than direct `push!(seen, l)` when `label` has few unique elements relative
203203
# to `length(label)`

0 commit comments

Comments
 (0)