summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-10-31 12:54:28 -0500
committerLuke Kanies <luke@madstop.com>2007-10-31 12:54:28 -0500
commitef9949502a1e393d14e8289c507ee3f3509a5350 (patch)
treedce089552e88acff95c01acf9a0c3bfc7e7a8260 /lib/puppet
parent826efe8d453c1cc45a980603fffc10c91fa0e267 (diff)
downloadpuppet-ef9949502a1e393d14e8289c507ee3f3509a5350.tar.gz
puppet-ef9949502a1e393d14e8289c507ee3f3509a5350.tar.xz
puppet-ef9949502a1e393d14e8289c507ee3f3509a5350.zip
Caching the 'parent' value, which resulted in
a drastic performance increase. However, profiling has shown that GRATR just isn't going to cut it. I think I'm going to have to replace it as my graphing base class to avoid the horrible, horrible performance I keep encountering.
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/type.rb27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 0a6ccdaa4..b7ff1f664 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -316,19 +316,22 @@ class Type
def parent
return nil unless configuration
- # This is kinda weird.
- if implicit?
- parents = configuration.relationship_graph.adjacent(self, :direction => :in)
- else
- parents = configuration.adjacent(self, :direction => :in)
- end
- if parents
- # We should never have more than one parent, so let's just ignore
- # it if we happen to.
- return parents.shift
- else
- return nil
+ unless defined?(@parent)
+ # This is kinda weird.
+ if implicit?
+ parents = configuration.relationship_graph.adjacent(self, :direction => :in)
+ else
+ parents = configuration.adjacent(self, :direction => :in)
+ end
+ if parents
+ # We should never have more than one parent, so let's just ignore
+ # it if we happen to.
+ @parent = parents.shift
+ else
+ @parent = nil
+ end
end
+ @parent
end
# Return the "type[name]" style reference.