File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -340,14 +340,15 @@ Base.fill!(A::CategoricalArray, v::Any) =
340
340
341
341
function mergelevels (ordered, levels... )
342
342
T = Base. promote_eltype (levels... )
343
- res = Array {T} (uninitialized, 0 )
343
+ res = Vector {T} (uninitialized, 0 )
344
344
345
- # Fast path in case all levels are equal
346
- if all (l -> l == levels[ 1 ], levels[ 2 : end ])
347
- append! (res, levels[ 1 ])
345
+ nonempty_lv = findfirst ( ! isempty, levels)
346
+ if nonempty_lv == 0
347
+ # no levels
348
348
return res, ordered
349
- elseif sum (l -> ! isempty (l), levels) == 1
350
- append! (res, levels[findfirst (l -> ! isempty (l), levels)])
349
+ elseif all (l -> isempty (l) || l == levels[nonempty_lv], levels)
350
+ # Fast path if all non-empty levels are equal
351
+ append! (res, levels[nonempty_lv])
351
352
return res, ordered
352
353
end
353
354
You can’t perform that action at this time.
0 commit comments