From 51bfd4fc1e9b2653d369663b8414638f6b2c8a64 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 20 Apr 2013 13:48:49 -0500 Subject: [PATCH] Avoid calling to_s on the same Pathname multiple times --- Library/Homebrew/extend/pathname.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 07526f0a29..df8f3813eb 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