From 8bf34294e538a46cf36d10cc2ae6934517ec9952 Mon Sep 17 00:00:00 2001 From: Nicholas Bauer Date: Sat, 1 Oct 2022 02:52:22 -0400 Subject: [PATCH] more efficient `DefaultsDict` iteration (#121) --- RecipesPipeline/src/utils.jl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/RecipesPipeline/src/utils.jl b/RecipesPipeline/src/utils.jl index 3087b58f1..7768f32d2 100644 --- a/RecipesPipeline/src/utils.jl +++ b/RecipesPipeline/src/utils.jl @@ -33,9 +33,7 @@ function Base.delete!(dd::DefaultsDict, k) end Base.length(dd::DefaultsDict) = length(union(keys(dd.explicit), keys(dd.defaults))) function Base.iterate(dd::DefaultsDict) - exp_keys = keys(dd.explicit) - def_keys = setdiff(keys(dd.defaults), exp_keys) - key_list = collect(Iterators.flatten((exp_keys, def_keys))) + key_list = union!(collect(keys(dd.explicit)), keys(dd.defaults)) iterate(dd, (key_list, 1)) end function Base.iterate(dd::DefaultsDict, (key_list, i))