From 948fdfba6a014901e7e460a2e9518cc90c23c462 Mon Sep 17 00:00:00 2001 From: Nicholas Bauer Date: Sat, 1 Oct 2022 16:01:30 -0400 Subject: [PATCH] DefaultsDict - correctness and performance tweaks for large numbers of series (#126) --- RecipesPipeline/src/utils.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RecipesPipeline/src/utils.jl b/RecipesPipeline/src/utils.jl index 5de461a80..dfeecda57 100644 --- a/RecipesPipeline/src/utils.jl +++ b/RecipesPipeline/src/utils.jl @@ -30,6 +30,7 @@ end function Base.delete!(dd::DefaultsDict, k) haskey(dd.explicit, k) && delete!(dd.explicit, k) haskey(dd.defaults, k) && delete!(dd.defaults, k) + return dd end Base.length(dd::DefaultsDict) = length(union(keys(dd.explicit), keys(dd.defaults))) function Base.iterate(dd::DefaultsDict) @@ -50,7 +51,10 @@ isdefault(dd::DefaultsDict, k) = !is_explicit(dd, k) && haskey(dd.defaults, k) Base.setindex!(dd::DefaultsDict, v, k) = dd.explicit[k] = v # Reset to default value and return dict -reset_kw!(dd::DefaultsDict, k) = is_explicit(dd, k) ? delete!(dd.explicit, k) : dd +function reset_kw!(dd::DefaultsDict, k) + is_explicit(dd, k) && delete!(dd.explicit, k) + return dd +end # Reset to default value and return old value pop_kw!(dd::DefaultsDict, k) = is_explicit(dd, k) ? pop!(dd.explicit, k) : dd.defaults[k] pop_kw!(dd::DefaultsDict, k, default) =