summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/interpreter.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-07-20 03:36:54 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-07-20 03:36:54 +0000
commit7401adac175c23fc404f691f7837c11f9cfbf80f (patch)
treea804d87adeaf2bbc822493e61d6d9a5a3c019026 /lib/puppet/parser/interpreter.rb
parent3f1b95790acb335977d0862aa39744d0e3df6629 (diff)
downloadpuppet-7401adac175c23fc404f691f7837c11f9cfbf80f.tar.gz
puppet-7401adac175c23fc404f691f7837c11f9cfbf80f.tar.xz
puppet-7401adac175c23fc404f691f7837c11f9cfbf80f.zip
Caching whether a given file or module has been loaded, because the loading was greedy and was causing files to get loaded every time a class or module was asked for
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2720 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser/interpreter.rb')
-rw-r--r--lib/puppet/parser/interpreter.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index 0e81c109f..b4936dd23 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -361,6 +361,7 @@ class Puppet::Parser::Interpreter
end
@files = []
+ @loaded = []
# Create our parser object
parsefiles
@@ -384,15 +385,19 @@ class Puppet::Parser::Interpreter
loaded = false
# First try to load the top-level module
mod = filename.scan(/^[\w-]+/).shift
- begin
- @parser.import(mod)
- Puppet.info "Autoloaded module %s" % mod
- loaded = true
- rescue Puppet::ImportError => detail
- # We couldn't load the module
+ unless @loaded.include?(mod)
+ @loaded << mod
+ begin
+ @parser.import(mod)
+ Puppet.info "Autoloaded module %s" % mod
+ loaded = true
+ rescue Puppet::ImportError => detail
+ # We couldn't load the module
+ end
end
- unless filename == mod
+ unless filename == mod and ! @loaded.include?(mod)
+ @loaded << mod
# Then the individual file
begin
@parser.import(filename)