diff options
author | John Keiser <john@johnkeiser.com> | 2015-06-06 10:50:02 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-06-08 08:44:39 -0700 |
commit | 8d4e9d44995d6f7de5a0b681616ed8241e39ece3 (patch) | |
tree | d23d7be8cbd127f0557b68e3487d994a000c3f98 /lib/chef/resource.rb | |
parent | a6aa7b65b54173324c93f5f3f73c66c724ca963e (diff) | |
download | chef-8d4e9d44995d6f7de5a0b681616ed8241e39ece3.tar.gz |
Improve performance of method_missingjk/perf
by not repeatedly sorting and calling enabled_handlers
(This was causing major slowdown in tests)
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r-- | lib/chef/resource.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index ab955f5454..d74b942e7d 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -1088,10 +1088,30 @@ class Chef # NOTE: that we do not support unregistering classes as descendents like # we used to for LWRP unloading because that was horrible and removed in # Chef-12. + # @deprecated + # @api private alias :resource_classes :descendants + # @deprecated + # @api private alias :find_subclass_by_name :find_descendants_by_name end + # @deprecated + # @api private + # We memoize a sorted version of descendants so that resource lookups don't + # have to sort all the things, all the time. + # This was causing performance issues in test runs, and probably in real + # life as well. + @@sorted_descendants = nil + def self.sorted_descendants + @@sorted_descendants ||= descendants.sort_by { |x| x.to_s } + end + def self.inherited(other) + super + @@sorted_descendants = nil + end + + # If an unknown method is invoked, determine whether the enclosing Provider's # lexical scope can fulfill the request. E.g. This happens when the Resource's # block invokes new_resource. |