summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/resource/param.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-22 04:56:05 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-22 04:56:05 +0000
commit5bd0e8c6035e5d175c6c609813e844ae3a77a055 (patch)
tree22f04c756f0a3ed1360d4a901c379b7be83f7129 /lib/puppet/parser/resource/param.rb
parent4c357d84960bc3cbaf26db8d9a94eccbf95f9a34 (diff)
downloadpuppet-5bd0e8c6035e5d175c6c609813e844ae3a77a055.tar.gz
puppet-5bd0e8c6035e5d175c6c609813e844ae3a77a055.tar.xz
puppet-5bd0e8c6035e5d175c6c609813e844ae3a77a055.zip
Rails is now significantly faster. I refactored all of the queries; they are mostly reduced to three queries, each of which is relatively fast, although there are still a ton of file- and tag-related queries that I cannot find the source of. Note that this speedup requires indexes, which will only get added if you start puppetmasterd with --dbmigrate (although you cannot always start with that, as there is an error in the init code). I expect that the indexes will not help unless you forcibly reindex your database, but after that you should see significant speed improvements.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2344 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser/resource/param.rb')
-rw-r--r--lib/puppet/parser/resource/param.rb31
1 files changed, 25 insertions, 6 deletions
diff --git a/lib/puppet/parser/resource/param.rb b/lib/puppet/parser/resource/param.rb
index 1f7a66aae..56a50de1c 100644
--- a/lib/puppet/parser/resource/param.rb
+++ b/lib/puppet/parser/resource/param.rb
@@ -16,10 +16,12 @@ class Puppet::Parser::Resource::Param
end
# Store this parameter in a Rails db.
- def to_rails(res)
+ def to_rails(res, pn = nil)
values = value.is_a?(Array) ? value : [value]
- unless pn = res.param_names.find_by_name(self.name.to_s)
+ values = values.collect { |v| v.to_s }
+
+ unless pn
# We're creating it anew.
pn = res.param_names.build(:name => self.name.to_s)
end
@@ -30,13 +32,30 @@ class Puppet::Parser::Resource::Param
pn.line = Integer(l)
end
- pn.collection_merge(:param_values, values) do |value|
- unless pv = pn.param_values.find_by_value(value)
- pv = pn.param_values.build(:value => value)
+ oldvals = []
+
+ if pv = pn.param_values
+ newvals = pv.each do |val|
+ oldvals << val.value
+ end
+ end
+
+ if oldvals != values
+ #pn.param_values = values.collect { |v| pn.param_values.build(:value => v.to_s) }
+ objects = values.collect do |v|
+ pn.param_values.build(:value => v.to_s)
end
- pv
+ pn.param_values = objects
+ #pn.save
end
+# pn.collection_merge(:param_values, values) do |value|
+# unless pv = pn.param_values.find_by_value(value)
+# pv = pn.param_values.build(:value => value)
+# end
+# pv
+# end
+
return pn
end