aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-05-06 16:52:26 -0500
committerJack Nagel2013-05-06 16:52:26 -0500
commit5bf652ecddff309934184f781059f677c7ff3a6f (patch)
tree3011acb0c7826a4098a31fd7db8b681c3ec2f3db /Library
parentb32202033881d93849f4c44a837389e8a9d450ef (diff)
downloadbrew-5bf652ecddff309934184f781059f677c7ff3a6f.tar.bz2
Avoid extra array allocations
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/options.rb15
-rw-r--r--Library/Homebrew/version.rb2
2 files changed, 10 insertions, 7 deletions
diff --git a/Library/Homebrew/options.rb b/Library/Homebrew/options.rb
index a57dafb85..7bfbb6a8c 100644
--- a/Library/Homebrew/options.rb
+++ b/Library/Homebrew/options.rb
@@ -106,13 +106,16 @@ class Options
when self then arg
when Option then new << arg
when Array
- opts = arg.map do |_arg|
- case _arg
- when /^-[^-]+$/ then _arg[1..-1].split(//)
- else _arg
+ opts = new
+ arg.each do |a|
+ case a
+ when /^-[^-]+$/
+ a[1..-1].split(//).each { |o| opts << Option.new(o) }
+ else
+ opts << Option.new(a)
end
- end.flatten
- new(opts.map { |o| Option.new(o) })
+ end
+ opts
else
raise TypeError, "Cannot convert #{arg.inspect} to Options"
end
diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb
index 01e87c5d6..9669c2af3 100644
--- a/Library/Homebrew/version.rb
+++ b/Library/Homebrew/version.rb
@@ -97,7 +97,7 @@ class Version
protected
def to_a
- @array ||= @version.scan(/\d+|[a-zA-Z]+/).map { |e| VersionElement.new(e) }
+ @array ||= @version.scan(/\d+|[a-zA-Z]+/).map! { |e| VersionElement.new(e) }
end
def self.parse spec