summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/compiler.rb
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-18 13:25:43 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-18 19:41:01 -0700
commitdd03ac9fa29fce36eb64a5f831be8757f2f96f5c (patch)
tree16738f07b08bd1069b3e55ce0468a51220ede02a /lib/puppet/parser/compiler.rb
parent4ce33fde2c0de19d03bf5d951858dd3ea4fd52a6 (diff)
downloadpuppet-dd03ac9fa29fce36eb64a5f831be8757f2f96f5c.tar.gz
puppet-dd03ac9fa29fce36eb64a5f831be8757f2f96f5c.tar.xz
puppet-dd03ac9fa29fce36eb64a5f831be8757f2f96f5c.zip
Partial fix for #4278 -- the performance aspects
unevaluated_resources was a performance bottleneck and was doing a great deal of unneeded work, such as searching for the type of evaluated resources before ignoring them because only unevaluated resources were wanted. This patch is behaviour neutral but gives a 2-3x speedup for compiles with many defined resources.
Diffstat (limited to 'lib/puppet/parser/compiler.rb')
-rw-r--r--lib/puppet/parser/compiler.rb23
1 files changed, 3 insertions, 20 deletions
diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb
index 85980722c..a901c0dd6 100644
--- a/lib/puppet/parser/compiler.rb
+++ b/lib/puppet/parser/compiler.rb
@@ -251,19 +251,7 @@ class Puppet::Parser::Compiler
# evaluate_generators loop.
def evaluate_definitions
exceptwrap do
- if ary = unevaluated_resources
- evaluated = false
- ary.each do |resource|
- if not resource.virtual?
- resource.evaluate
- evaluated = true
- end
- end
- # If we evaluated, let the loop know.
- return evaluated
- else
- return false
- end
+ !unevaluated_resources.each { |resource| resource.evaluate }.empty?
end
end
@@ -482,12 +470,7 @@ class Puppet::Parser::Compiler
# Return an array of all of the unevaluated resources. These will be definitions,
# which need to get evaluated into native resources.
def unevaluated_resources
- ary = resources.reject { |resource| resource.builtin? or resource.evaluated? }
-
- if ary.empty?
- return nil
- else
- return ary
- end
+ # The order of these is significant for speed due to short-circuting
+ resources.reject { |resource| resource.evaluated? or resource.virtual? or resource.builtin_type? }
end
end