diff options
| author | Jack Nagel | 2013-04-20 13:48:49 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-04-20 13:50:42 -0500 |
| commit | 9d1a86cda130fb067a1d2b0d24f94e33b3ed4abb (patch) | |
| tree | 09389c955a48b706672b94ddfd39c845a64ba5ab /Library | |
| parent | c2c6e21f20d167df89e26f3660027a3bb0f1d4a8 (diff) | |
| download | homebrew-9d1a86cda130fb067a1d2b0d24f94e33b3ed4abb.tar.bz2 | |
Avoid calling to_s on the same Pathname multiple times
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 07526f0a2..df8f3813e 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -122,17 +122,17 @@ class Pathname # extended to support common double extensions alias extname_old extname - def extname - BOTTLE_EXTNAME_RX.match to_s + def extname(path=to_s) + BOTTLE_EXTNAME_RX.match(path) return $1 if $1 - /(\.(tar|cpio)\.(gz|bz2|xz|Z))$/.match to_s + /(\.(tar|cpio)\.(gz|bz2|xz|Z))$/.match(path) return $1 if $1 - return File.extname(to_s) + return File.extname(path) end # for filetypes we support, basename without extension def stem - return File.basename(to_s, extname) + File.basename((path = to_s), extname(path)) end # I don't trust the children.length == 0 check particularly, not to mention |
