Avoid expensive Pathname concatenation
This commit is contained in:
parent
841c8bedca
commit
49682e854d
@ -37,13 +37,13 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
|
|||||||
super
|
super
|
||||||
|
|
||||||
if name.to_s.empty? || name == '__UNKNOWN__'
|
if name.to_s.empty? || name == '__UNKNOWN__'
|
||||||
@tarball_path = HOMEBREW_CACHE + File.basename(@url)
|
@tarball_path = Pathname.new("#{HOMEBREW_CACHE}/#{File.basename(@url)}")
|
||||||
else
|
else
|
||||||
@tarball_path = HOMEBREW_CACHE + "#{name}-#{package.version}#{ext}"
|
@tarball_path = Pathname.new("#{HOMEBREW_CACHE}/#{name}-#{package.version}#{ext}")
|
||||||
end
|
end
|
||||||
|
|
||||||
@mirrors = package.mirrors
|
@mirrors = package.mirrors
|
||||||
@temporary_path = Pathname("#@tarball_path.incomplete")
|
@temporary_path = Pathname.new("#@tarball_path.incomplete")
|
||||||
@local_bottle_path = nil
|
@local_bottle_path = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ class SubversionDownloadStrategy < AbstractDownloadStrategy
|
|||||||
if name.to_s.empty? || name == '__UNKNOWN__'
|
if name.to_s.empty? || name == '__UNKNOWN__'
|
||||||
raise NotImplementedError, "strategy requires a name parameter"
|
raise NotImplementedError, "strategy requires a name parameter"
|
||||||
else
|
else
|
||||||
@co = HOMEBREW_CACHE + "#{name}--svn"
|
@co = Pathname.new("#{HOMEBREW_CACHE}/#{name}--svn")
|
||||||
end
|
end
|
||||||
|
|
||||||
@co += "-HEAD" if ARGV.build_head?
|
@co += "-HEAD" if ARGV.build_head?
|
||||||
@ -316,7 +316,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
|
|||||||
if name.to_s.empty? || name == '__UNKNOWN__'
|
if name.to_s.empty? || name == '__UNKNOWN__'
|
||||||
raise NotImplementedError, "strategy requires a name parameter"
|
raise NotImplementedError, "strategy requires a name parameter"
|
||||||
else
|
else
|
||||||
@clone = HOMEBREW_CACHE + "#{name}--git"
|
@clone = Pathname.new("#{HOMEBREW_CACHE}/#{name}--git")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -116,16 +116,16 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
def linked_keg
|
def linked_keg
|
||||||
HOMEBREW_REPOSITORY/'Library/LinkedKegs'/name
|
Pathname.new("#{HOMEBREW_LIBRARY}/LinkedKegs/#{name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def installed_prefix
|
def installed_prefix
|
||||||
devel_prefix = unless devel.nil?
|
devel_prefix = unless devel.nil?
|
||||||
HOMEBREW_CELLAR/name/devel.version
|
Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{devel.version}")
|
||||||
end
|
end
|
||||||
|
|
||||||
head_prefix = unless head.nil?
|
head_prefix = unless head.nil?
|
||||||
HOMEBREW_CELLAR/name/head.version
|
Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{head.version}")
|
||||||
end
|
end
|
||||||
|
|
||||||
if active_spec == head || head and head_prefix.directory?
|
if active_spec == head || head and head_prefix.directory?
|
||||||
@ -143,7 +143,7 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
def prefix
|
def prefix
|
||||||
HOMEBREW_CELLAR+name+version
|
Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{version}")
|
||||||
end
|
end
|
||||||
def rack; prefix.parent end
|
def rack; prefix.parent end
|
||||||
|
|
||||||
@ -185,7 +185,9 @@ class Formula
|
|||||||
# Defined and active build-time options.
|
# Defined and active build-time options.
|
||||||
def build; self.class.build; end
|
def build; self.class.build; end
|
||||||
|
|
||||||
def opt_prefix; HOMEBREW_PREFIX/:opt/name end
|
def opt_prefix
|
||||||
|
Pathname.new("#{HOMEBREW_PREFIX}/opt/#{name}")
|
||||||
|
end
|
||||||
|
|
||||||
def download_strategy
|
def download_strategy
|
||||||
active_spec.download_strategy
|
active_spec.download_strategy
|
||||||
@ -350,13 +352,14 @@ class Formula
|
|||||||
def self.canonical_name name
|
def self.canonical_name name
|
||||||
name = name.to_s if name.kind_of? Pathname
|
name = name.to_s if name.kind_of? Pathname
|
||||||
|
|
||||||
formula_with_that_name = HOMEBREW_REPOSITORY+"Library/Formula/#{name}.rb"
|
formula_with_that_name = Pathname.new("#{HOMEBREW_REPOSITORY}/Library/Formula/#{name}.rb")
|
||||||
possible_alias = HOMEBREW_REPOSITORY+"Library/Aliases/#{name}"
|
possible_alias = Pathname.new("#{HOMEBREW_REPOSITORY}/Library/Aliases/#{name}")
|
||||||
possible_cached_formula = HOMEBREW_CACHE_FORMULA+"#{name}.rb"
|
possible_cached_formula = Pathname.new("#{HOMEBREW_CACHE_FORMULA}/#{name}.rb")
|
||||||
|
|
||||||
if name.include? "/"
|
if name.include? "/"
|
||||||
if name =~ %r{(.+)/(.+)/(.+)}
|
if name =~ %r{(.+)/(.+)/(.+)}
|
||||||
tapd = HOMEBREW_REPOSITORY/"Library/Taps"/"#$1-#$2".downcase
|
tap_name = "#$1-#$2".downcase
|
||||||
|
tapd = Pathname.new("#{HOMEBREW_REPOSITORY}/Library/Taps/#{tap_name}")
|
||||||
tapd.find_formula do |relative_pathname|
|
tapd.find_formula do |relative_pathname|
|
||||||
return "#{tapd}/#{relative_pathname}" if relative_pathname.stem.to_s == $3
|
return "#{tapd}/#{relative_pathname}" if relative_pathname.stem.to_s == $3
|
||||||
end if tapd.directory?
|
end if tapd.directory?
|
||||||
@ -472,7 +475,7 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.path name
|
def self.path name
|
||||||
HOMEBREW_REPOSITORY+"Library/Formula/#{name.downcase}.rb"
|
Pathname.new("#{HOMEBREW_REPOSITORY}/Library/Formula/#{name.downcase}.rb")
|
||||||
end
|
end
|
||||||
|
|
||||||
def deps; self.class.dependencies.deps; end
|
def deps; self.class.dependencies.deps; end
|
||||||
|
|||||||
@ -33,15 +33,15 @@ module MacOS::Xcode extend self
|
|||||||
def prefix
|
def prefix
|
||||||
@prefix ||= begin
|
@prefix ||= begin
|
||||||
path = Pathname.new(folder)
|
path = Pathname.new(folder)
|
||||||
if path.absolute? and (path/'usr/bin/make').executable?
|
if path.absolute? and File.executable? "#{path}/usr/bin/make"
|
||||||
path
|
path
|
||||||
elsif File.executable? '/Developer/usr/bin/make'
|
elsif File.executable? '/Developer/usr/bin/make'
|
||||||
# we do this to support cowboys who insist on installing
|
# we do this to support cowboys who insist on installing
|
||||||
# only a subset of Xcode
|
# only a subset of Xcode
|
||||||
Pathname.new '/Developer'
|
Pathname.new('/Developer')
|
||||||
elsif (V4_BUNDLE_PATH/'Contents/Developer/usr/bin/make').executable?
|
elsif File.executable? "#{V4_BUNDLE_PATH}/Contents/Developer/usr/bin/make"
|
||||||
# fallback for broken Xcode 4.3 installs
|
# fallback for broken Xcode 4.3 installs
|
||||||
V4_BUNDLE_PATH/'Contents/Developer'
|
Pathname.new("#{V4_BUNDLE_PATH}/Contents/Developer")
|
||||||
else
|
else
|
||||||
# Ask Spotlight where Xcode is. If the user didn't install the
|
# Ask Spotlight where Xcode is. If the user didn't install the
|
||||||
# helper tools and installed Xcode in a non-conventional place, this
|
# helper tools and installed Xcode in a non-conventional place, this
|
||||||
@ -51,7 +51,7 @@ module MacOS::Xcode extend self
|
|||||||
|
|
||||||
unless path.nil?
|
unless path.nil?
|
||||||
path += "Contents/Developer"
|
path += "Contents/Developer"
|
||||||
path if (path/'usr/bin/make').executable?
|
path if File.executable? "#{path}/usr/bin/make"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -76,7 +76,7 @@ module MacOS::Xcode extend self
|
|||||||
|
|
||||||
# this shortcut makes version work for people who don't realise you
|
# this shortcut makes version work for people who don't realise you
|
||||||
# need to install the CLI tools
|
# need to install the CLI tools
|
||||||
xcode43build = prefix/'usr/bin/xcodebuild'
|
xcode43build = Pathname.new("#{prefix}/usr/bin/xcodebuild")
|
||||||
if xcode43build.file?
|
if xcode43build.file?
|
||||||
`#{xcode43build} -version 2>/dev/null` =~ /Xcode (\d(\.\d)*)/
|
`#{xcode43build} -version 2>/dev/null` =~ /Xcode (\d(\.\d)*)/
|
||||||
return $1 if $1
|
return $1 if $1
|
||||||
|
|||||||
@ -70,27 +70,27 @@ module MacOS::X11 extend self
|
|||||||
# Confusingly, executables (e.g. config scripts) are only found under
|
# Confusingly, executables (e.g. config scripts) are only found under
|
||||||
# /opt/X11/bin or /usr/X11/bin in all cases.
|
# /opt/X11/bin or /usr/X11/bin in all cases.
|
||||||
def bin
|
def bin
|
||||||
prefix/'bin'
|
Pathname.new("#{prefix}/bin")
|
||||||
end
|
end
|
||||||
|
|
||||||
def include
|
def include
|
||||||
@include ||= if use_sdk?
|
@include ||= if use_sdk?
|
||||||
MacOS.sdk_path/'usr/X11/include'
|
Pathname.new("#{MacOS.sdk_path}/usr/X11/include")
|
||||||
else
|
else
|
||||||
prefix/'include'
|
Pathname.new("#{prefix}/include")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def lib
|
def lib
|
||||||
@lib ||= if use_sdk?
|
@lib ||= if use_sdk?
|
||||||
MacOS.sdk_path/'usr/X11/lib'
|
Pathname.new("#{MacOS.sdk_path}/usr/X11/lib")
|
||||||
else
|
else
|
||||||
prefix/'lib'
|
Pathname.new("#{prefix}/lib")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def share
|
def share
|
||||||
prefix/'share'
|
Pathname.new("#{prefix}/share")
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user