From 6524dfc17b95c2944829f8264300cf60d49f5250 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 7 Jun 2014 17:45:13 -0500 Subject: [PATCH] metafiles: reduce pathname conversions in #include? --- Library/Homebrew/metafiles.rb | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/metafiles.rb b/Library/Homebrew/metafiles.rb index e01ca2f151..9f740781fd 100644 --- a/Library/Homebrew/metafiles.rb +++ b/Library/Homebrew/metafiles.rb @@ -22,17 +22,16 @@ class Metafiles private - def include? p - p = p.to_s # Might be a pathname - p = p.downcase - path = Pathname.new(p) - if @exts.include? path.extname - p = path.basename(path.extname) - else - p = path.basename - end - p = p.to_s - return @metafiles.include? p - end + def include?(path) + path = path.to_s.downcase + ext = File.extname(path) + if EXTENSIONS.include?(ext) + file = File.basename(path, ext) + else + file = File.basename(path) + end + + return @metafiles.include?(file) + end end