diff options
| author | Luke Kanies <luke@madstop.com> | 2008-03-21 00:39:26 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-03-21 00:39:26 -0500 |
| commit | 18320b8e3271f7d1d1702907be1ff420acfc8d2b (patch) | |
| tree | 159cde5158579fc3b0ae6e502c25b32752d7561c /lib | |
| parent | f6325dceb3b10c300f421f540281bbd64bdc091e (diff) | |
| download | puppet-18320b8e3271f7d1d1702907be1ff420acfc8d2b.tar.gz puppet-18320b8e3271f7d1d1702907be1ff420acfc8d2b.tar.xz puppet-18320b8e3271f7d1d1702907be1ff420acfc8d2b.zip | |
Found all instances of methods where split() is used without
any local variables and added a local variable -- see
http://snurl.com/21zf8. My own testing showed that this
caused memory growth to level off at a reasonable level.
Note that the link above says the problem is only with class
methods, but my own testing showed that it's any method that
meets these criteria. This is not a functional change, but
should hopefully be the last nail in the coffin of #1131.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/file_serving/configuration/parser.rb | 6 | ||||
| -rw-r--r-- | lib/puppet/indirector/facts/facter.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/indirector/node/ldap.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/indirector/report/processor.rb | 3 | ||||
| -rwxr-xr-x | lib/puppet/network/authstore.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/network/client/master.rb | 6 | ||||
| -rwxr-xr-x | lib/puppet/network/handler/report.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/network/http/mongrel/rest.rb | 6 | ||||
| -rw-r--r-- | lib/puppet/network/http/webrick/rest.rb | 8 | ||||
| -rw-r--r-- | lib/puppet/node/environment.rb | 3 | ||||
| -rwxr-xr-x | lib/puppet/provider/mailalias/aliases.rb | 5 | ||||
| -rw-r--r-- | lib/puppet/provider/zone/solaris.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/resource_reference.rb | 3 | ||||
| -rwxr-xr-x | lib/puppet/type/host.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/type/service.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/util.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/util/constant_inflector.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/util/fileparsing.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/util/tagging.rb | 3 |
19 files changed, 50 insertions, 24 deletions
diff --git a/lib/puppet/file_serving/configuration/parser.rb b/lib/puppet/file_serving/configuration/parser.rb index 707c3f9b1..cda6889d4 100644 --- a/lib/puppet/file_serving/configuration/parser.rb +++ b/lib/puppet/file_serving/configuration/parser.rb @@ -62,7 +62,8 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile # Allow a given pattern access to a mount. def allow(mount, value) - value.split(/\s*,\s*/).each { |val| + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = value.split(/\s*,\s*/).each { |val| begin mount.info "allowing %s access" % val mount.allow(val) @@ -75,7 +76,8 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile # Deny a given pattern access to a mount. def deny(mount, value) - value.split(/\s*,\s*/).each { |val| + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = value.split(/\s*,\s*/).each { |val| begin mount.info "denying %s access" % val mount.deny(val) diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb index 5b9a7b3c0..a8c47e3bf 100644 --- a/lib/puppet/indirector/facts/facter.rb +++ b/lib/puppet/indirector/facts/facter.rb @@ -23,7 +23,8 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code end def self.loadfacts - Puppet[:factpath].split(":").each do |dir| + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = Puppet[:factpath].split(":").each do |dir| loaddir(dir, "fact") end end diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb index 8537e1cf3..73b5cdd70 100644 --- a/lib/puppet/indirector/node/ldap.rb +++ b/lib/puppet/indirector/node/ldap.rb @@ -7,7 +7,8 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap # The attributes that Puppet class information is stored in. def class_attributes - Puppet[:ldapclassattrs].split(/\s*,\s*/) + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = Puppet[:ldapclassattrs].split(/\s*,\s*/) end # Look for our node in ldap. diff --git a/lib/puppet/indirector/report/processor.rb b/lib/puppet/indirector/report/processor.rb index fd1bc413a..fa2b7f36b 100644 --- a/lib/puppet/indirector/report/processor.rb +++ b/lib/puppet/indirector/report/processor.rb @@ -45,6 +45,7 @@ class Puppet::Transaction::Report::Processor < Puppet::Indirector::Code # Handle the parsing of the reports attribute. def reports - Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/) + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/) end end diff --git a/lib/puppet/network/authstore.rb b/lib/puppet/network/authstore.rb index c16bef32f..cb1fdc57d 100755 --- a/lib/puppet/network/authstore.rb +++ b/lib/puppet/network/authstore.rb @@ -235,7 +235,8 @@ module Puppet # Convert the name to a common pattern. def munge_name(name) - name.downcase.split(".").reverse + # LAK:NOTE http://snurl.com/21zf8 [groups_google_com] + x = name.downcase.split(".").reverse end # Parse our input pattern and figure out what kind of allowal diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index e914d5c69..955acbfb5 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -50,7 +50,8 @@ class Puppet::Network::Client::Master < Puppet::Network::Client # Return the list of dynamic facts as an array of symbols def self.dynamic_facts - Puppet.settings[:dynamicfacts].split(/\s*,\s*/).collect { |fact| fact.downcase } + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = Puppet.settings[:dynamicfacts].split(/\s*,\s*/).collect { |fact| fact.downcase } end # Cache the config @@ -425,7 +426,8 @@ class Puppet::Network::Client::Master < Puppet::Network::Client end def self.loadfacts - Puppet[:factpath].split(":").each do |dir| + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = Puppet[:factpath].split(":").each do |dir| loaddir(dir, "fact") end end diff --git a/lib/puppet/network/handler/report.rb b/lib/puppet/network/handler/report.rb index 8ddeed9f6..b92b77ea5 100755 --- a/lib/puppet/network/handler/report.rb +++ b/lib/puppet/network/handler/report.rb @@ -79,7 +79,8 @@ class Puppet::Network::Handler # Handle the parsing of the reports attribute. def reports - Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/) + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = Puppet[:reports].gsub(/(^\s+)|(\s+$)/, '').split(/\s*,\s*/) end end end diff --git a/lib/puppet/network/http/mongrel/rest.rb b/lib/puppet/network/http/mongrel/rest.rb index db63613ab..6c24e360c 100644 --- a/lib/puppet/network/http/mongrel/rest.rb +++ b/lib/puppet/network/http/mongrel/rest.rb @@ -14,11 +14,13 @@ class Puppet::Network::HTTP::MongrelREST < Puppet::Network::HTTP::Handler end def path(request) - '/' + request.params[Mongrel::Const::REQUEST_PATH].split('/')[1] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = '/' + request.params[Mongrel::Const::REQUEST_PATH].split('/')[1] end def request_key(request) - request.params[Mongrel::Const::REQUEST_PATH].split('/')[2] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = request.params[Mongrel::Const::REQUEST_PATH].split('/')[2] end def body(request) diff --git a/lib/puppet/network/http/webrick/rest.rb b/lib/puppet/network/http/webrick/rest.rb index dd0c84d61..8cda079e2 100644 --- a/lib/puppet/network/http/webrick/rest.rb +++ b/lib/puppet/network/http/webrick/rest.rb @@ -19,11 +19,13 @@ class Puppet::Network::HTTP::WEBrickREST < Puppet::Network::HTTP::Handler end def path(request) - '/' + request.path.split('/')[1] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = '/' + request.path.split('/')[1] end def request_key(request) - request.path.split('/')[2] + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = request.path.split('/')[2] end def body(request) @@ -38,4 +40,4 @@ class Puppet::Network::HTTP::WEBrickREST < Puppet::Network::HTTP::Handler response.status = status response.body = result end -end
\ No newline at end of file +end diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb index 2a314803f..343720a62 100644 --- a/lib/puppet/node/environment.rb +++ b/lib/puppet/node/environment.rb @@ -4,7 +4,8 @@ class Puppet::Node::Environment # Return the list of valid environments. Just looks them up in # the settings. def self.valid - Puppet.settings.value(:environments).split(",").collect { |e| e.to_sym } + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = Puppet.settings.value(:environments).split(",").collect { |e| e.to_sym } end # Is the provided environment valid? diff --git a/lib/puppet/provider/mailalias/aliases.rb b/lib/puppet/provider/mailalias/aliases.rb index 85dec29cc..8b5c45617 100755 --- a/lib/puppet/provider/mailalias/aliases.rb +++ b/lib/puppet/provider/mailalias/aliases.rb @@ -10,7 +10,10 @@ Puppet::Type.type(:mailalias).provide(:aliases, record_line :aliases, :fields => %w{name recipient}, :separator => /\s*:\s*/, :block_eval => :instance do def post_parse(record) - record[:recipient] = record[:recipient].split(/\s*,\s*/).collect { |d| d.gsub(/^['"]|['"]$/, '') } + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # It's not sufficient to assign to an existing hash. + recipient = record[:recipient].split(/\s*,\s*/).collect { |d| d.gsub(/^['"]|['"]$/, '') } + record[:recipient] = recipient record end diff --git a/lib/puppet/provider/zone/solaris.rb b/lib/puppet/provider/zone/solaris.rb index dd8698b92..be2dd97f9 100644 --- a/lib/puppet/provider/zone/solaris.rb +++ b/lib/puppet/provider/zone/solaris.rb @@ -26,7 +26,8 @@ Puppet::Type.type(:zone).provide(:solaris) do end def self.instances - adm(:list, "-cp").split("\n").collect do |line| + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = adm(:list, "-cp").split("\n").collect do |line| new(line2hash(line)) end end diff --git a/lib/puppet/resource_reference.rb b/lib/puppet/resource_reference.rb index 771a91be7..44b518816 100644 --- a/lib/puppet/resource_reference.rb +++ b/lib/puppet/resource_reference.rb @@ -49,7 +49,8 @@ class Puppet::ResourceReference if value.nil? or value.to_s.downcase == "component" @type = "Class" else - @type = value.to_s.split("::").collect { |s| s.capitalize }.join("::") + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = @type = value.to_s.split("::").collect { |s| s.capitalize }.join("::") end end diff --git a/lib/puppet/type/host.rb b/lib/puppet/type/host.rb index 868e41629..53365bf40 100755 --- a/lib/puppet/type/host.rb +++ b/lib/puppet/type/host.rb @@ -87,7 +87,8 @@ module Puppet isnamevar validate do |value| - value.split('.').each do |hostpart| + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = value.split('.').each do |hostpart| unless hostpart =~ /^([\d\w]+|[\d\w][\d\w\-]+[\d\w])$/ raise Puppet::Error, "Invalid host name" end diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index 1b625cc41..560d81bae 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -113,7 +113,9 @@ module Puppet munge do |value| value = [value] unless value.is_a?(Array) - paths = value.flatten.collect { |p| p.split(":") }.flatten.find_all do |path| + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + # It affects stand-alone blocks, too. + paths = value.flatten.collect { |p| x = p.split(":") }.flatten.find_all do |path| if FileTest.directory?(path) true else diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index 2e83a08e9..560afe10b 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -226,7 +226,8 @@ module Util return nil end else - ENV['PATH'].split(":").each do |dir| + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = ENV['PATH'].split(":").each do |dir| if FileTest.exists? File.join(dir, bin) return File.join(dir, bin) end diff --git a/lib/puppet/util/constant_inflector.rb b/lib/puppet/util/constant_inflector.rb index 8b083951f..eeeaa0632 100644 --- a/lib/puppet/util/constant_inflector.rb +++ b/lib/puppet/util/constant_inflector.rb @@ -5,7 +5,8 @@ # file names. module Puppet::Util::ConstantInflector def file2constant(file) - file.split("/").collect { |name| name.capitalize }.join("::").gsub(/_+(.)/) { |term| $1.capitalize } + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = file.split("/").collect { |name| name.capitalize }.join("::").gsub(/_+(.)/) { |term| $1.capitalize } end def constant2file(constant) diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb index 8e39719c8..23d02ea60 100644 --- a/lib/puppet/util/fileparsing.rb +++ b/lib/puppet/util/fileparsing.rb @@ -223,7 +223,8 @@ module Puppet::Util::FileParsing # Split text into separate lines using the record separator. def lines(text) # Remove any trailing separators, and then split based on them - text.sub(/#{self.line_separator}\Q/,'').split(self.line_separator) + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + x = text.sub(/#{self.line_separator}\Q/,'').split(self.line_separator) end # Split a bunch of text into lines and then parse them individually. diff --git a/lib/puppet/util/tagging.rb b/lib/puppet/util/tagging.rb index 8a50f3458..e06e13a2c 100644 --- a/lib/puppet/util/tagging.rb +++ b/lib/puppet/util/tagging.rb @@ -16,7 +16,8 @@ module Puppet::Util::Tagging @tags << tag unless @tags.include?(tag) end - qualified.collect { |name| name.split("::") }.flatten.each { |tag| @tags << tag unless @tags.include?(tag) } + # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] + qualified.collect { |name| x = name.split("::") }.flatten.each { |tag| @tags << tag unless @tags.include?(tag) } end # Are we tagged with the provided tag? |
