diff options
| author | Jack Nagel | 2013-04-16 14:32:28 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-04-16 14:32:32 -0500 |
| commit | 42da1295cefa6cf0e0695bcf35bedfaab6dfe812 (patch) | |
| tree | 0b307dac0553c9c9b0d16c329a8a3d5688f43a6c | |
| parent | 1426b92a828821c01a3beab21a23ece79b303f23 (diff) | |
| download | brew-42da1295cefa6cf0e0695bcf35bedfaab6dfe812.tar.bz2 | |
Only call Pathname#to_s once per Version object
| -rw-r--r-- | Library/Homebrew/version.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index a72c4e617..0f0cc96f1 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -108,32 +108,34 @@ class Version def self._parse spec spec = Pathname.new(spec) unless spec.is_a? Pathname + spec_s = spec.to_s + stem = if spec.directory? spec.basename.to_s - elsif %r[((?:sourceforge.net|sf.net)/.*)/download$].match(spec.to_s) + elsif %r[((?:sourceforge.net|sf.net)/.*)/download$].match(spec_s) Pathname.new(spec.dirname).stem else spec.stem end # GitHub tarballs, e.g. v1.2.3 - m = %r[github.com/.+/(?:zip|tar)ball/v?((\d+\.)+\d+)$].match(spec.to_s) + m = %r[github.com/.+/(?:zip|tar)ball/v?((\d+\.)+\d+)$].match(spec_s) return m.captures.first unless m.nil? # e.g. https://github.com/sam-github/libnet/tarball/libnet-1.1.4 - m = %r[github.com/.+/(?:zip|tar)ball/.*-((\d+\.)+\d+)$].match(spec.to_s) + m = %r[github.com/.+/(?:zip|tar)ball/.*-((\d+\.)+\d+)$].match(spec_s) return m.captures.first unless m.nil? # e.g. https://github.com/isaacs/npm/tarball/v0.2.5-1 - m = %r[github.com/.+/(?:zip|tar)ball/v?((\d+\.)+\d+-(\d+))$].match(spec.to_s) + m = %r[github.com/.+/(?:zip|tar)ball/v?((\d+\.)+\d+-(\d+))$].match(spec_s) return m.captures.first unless m.nil? # e.g. https://github.com/petdance/ack/tarball/1.93_02 - m = %r[github.com/.+/(?:zip|tar)ball/v?((\d+\.)+\d+_(\d+))$].match(spec.to_s) + m = %r[github.com/.+/(?:zip|tar)ball/v?((\d+\.)+\d+_(\d+))$].match(spec_s) return m.captures.first unless m.nil? # e.g. https://github.com/erlang/otp/tarball/OTP_R15B01 (erlang style) - m = /[-_](R\d+[AB]\d*(-\d+)?)/.match(spec.to_s) + m = /[-_](R\d+[AB]\d*(-\d+)?)/.match(spec_s) return m.captures.first unless m.nil? # e.g. boost_1_39_0 @@ -182,7 +184,7 @@ class Version return m.captures.first unless m.nil? # e.g. http://mirrors.jenkins-ci.org/war/1.486/jenkins.war - m = /\/(\d\.\d+)\//.match(spec.to_s) + m = /\/(\d\.\d+)\//.match(spec_s) return m.captures.first unless m.nil? # e.g. http://www.ijg.org/files/jpegsrc.v8d.tar.gz |
