File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -194,11 +194,14 @@ function count_connected_components(
194194end
195195
196196function count_unique (label:: Vector{T} ) where {T}
197- # effectively does `length(Set(label))` but slightly faster since `Set(label)`
198- # sizehints too aggressively for the use case of having relatively few unique elements
197+ # effectively does `length(Set(label))` but faster, since `Set(label)` sizehints
198+ # aggressively and assumes that most elements of `label` will be unique, which very
199+ # rarely will be the case for caller `count_connected_components!`
199200 seen = Set {T} ()
200201 for l in label
201- l ∉ seen && push! (seen, l) # currently faster than direct `push!(seen, l)`
202+ # faster than direct `push!(seen, l)` when `label` has few unique elements relative
203+ # to `length(label)`
204+ l ∉ seen && push! (seen, l)
202205 end
203206 return length (seen)
204207end
You can’t perform that action at this time.
0 commit comments