diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2022-03-30 15:11:36 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2022-03-30 15:11:36 -0700 |
commit | cdeedccf715afe1d4361245a2a3194d8ca82ca09 (patch) | |
tree | ed845aab8981812c5fcdd3004ae00361eb79d2a5 /chef-utils | |
parent | 84d1f174842472dd87e322659beb65253f621a2b (diff) | |
download | chef-cdeedccf715afe1d4361245a2a3194d8ca82ca09.tar.gz |
Convert the deep merge cache to an ImmutableMash
This makes it so that callers can call the deep merge cache
more or less directly so that we're not hanging onto a weird
Hash-of-ImmutableMashes structure.
Care still needs to be taken to consider the fact that:
- the deep merge cache may not be merged for a given keys since
it is lazily created, so we need to hit the top level accessor
once to make sure the key is merged before we access it.
- the top-level "give me it all" case where the path is totally
empty is still handled by doing a manual deep merge of everything.
Once that is done we can call APIs like read/read!/exist? directly
on the ImmutableMash and have fewer edge cases to deal with.
This has the same perf speedup that the prior approach does and
keeps attribute mangling down to 1% of my runtime on my own cookbooks
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'chef-utils')
-rw-r--r-- | chef-utils/lib/chef-utils/mash.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/chef-utils/lib/chef-utils/mash.rb b/chef-utils/lib/chef-utils/mash.rb index bb48064aa3..14159d175a 100644 --- a/chef-utils/lib/chef-utils/mash.rb +++ b/chef-utils/lib/chef-utils/mash.rb @@ -106,6 +106,14 @@ module ChefUtils alias_method :regular_update, :update end + unless method_defined?(:regular_clear) + alias_method :regular_clear, :clear + end + + unless method_defined?(:regular_delete) + alias_method :regular_delete, :delete + end + # @param key<Object> The key to get. def [](key) regular_reader(key) |