[rubygems/rubygems] Use match? when regexp match data is unused
Improved performance / reduced allocations https://github.com/rubygems/rubygems/commit/b04726c9a7
This commit is contained in:
parent
b266890dab
commit
baf2ec2ca8
@ -127,8 +127,8 @@ module Bundler
|
|||||||
|
|
||||||
if man_pages.include?(command)
|
if man_pages.include?(command)
|
||||||
man_page = man_pages[command]
|
man_page = man_pages[command]
|
||||||
if Bundler.which("man") && man_path !~ %r{^file:/.+!/META-INF/jruby.home/.+}
|
if Bundler.which("man") && !man_path.match?(%r{^file:/.+!/META-INF/jruby.home/.+})
|
||||||
Kernel.exec "man #{man_page}"
|
Kernel.exec("man", man_page)
|
||||||
else
|
else
|
||||||
puts File.read("#{man_path}/#{File.basename(man_page)}.ronn")
|
puts File.read("#{man_path}/#{File.basename(man_page)}.ronn")
|
||||||
end
|
end
|
||||||
|
@ -54,7 +54,7 @@ module Bundler
|
|||||||
|
|
||||||
Bundler.definition.specs.each do |spec|
|
Bundler.definition.specs.each do |spec|
|
||||||
return spec if spec.name == name
|
return spec if spec.name == name
|
||||||
specs << spec if regexp && spec.name =~ regexp
|
specs << spec if regexp && spec.name.match?(regexp)
|
||||||
end
|
end
|
||||||
|
|
||||||
default_spec = default_gem_spec(name)
|
default_spec = default_gem_spec(name)
|
||||||
|
@ -329,7 +329,7 @@ module Bundler
|
|||||||
def set_rubyopt
|
def set_rubyopt
|
||||||
rubyopt = [ENV["RUBYOPT"]].compact
|
rubyopt = [ENV["RUBYOPT"]].compact
|
||||||
setup_require = "-r#{File.expand_path("setup", __dir__)}"
|
setup_require = "-r#{File.expand_path("setup", __dir__)}"
|
||||||
return if !rubyopt.empty? && rubyopt.first =~ /#{Regexp.escape(setup_require)}/
|
return if !rubyopt.empty? && rubyopt.first.include?(setup_require)
|
||||||
rubyopt.unshift setup_require
|
rubyopt.unshift setup_require
|
||||||
Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
|
Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
|
||||||
end
|
end
|
||||||
|
@ -87,7 +87,7 @@ module Bundler
|
|||||||
def contains?(commit)
|
def contains?(commit)
|
||||||
allowed_with_path do
|
allowed_with_path do
|
||||||
result, status = git_null("branch", "--contains", commit, dir: path)
|
result, status = git_null("branch", "--contains", commit, dir: path)
|
||||||
status.success? && result =~ /^\* (.*)$/
|
status.success? && result.match?(/^\* (.*)$/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ m = Module.new do
|
|||||||
bundler_version = nil
|
bundler_version = nil
|
||||||
update_index = nil
|
update_index = nil
|
||||||
ARGV.each_with_index do |a, i|
|
ARGV.each_with_index do |a, i|
|
||||||
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
|
||||||
bundler_version = a
|
bundler_version = a
|
||||||
end
|
end
|
||||||
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
||||||
|
@ -130,7 +130,7 @@ module Bundler
|
|||||||
def tell_err(message, color = nil, newline = nil)
|
def tell_err(message, color = nil, newline = nil)
|
||||||
return if @shell.send(:stderr).closed?
|
return if @shell.send(:stderr).closed?
|
||||||
|
|
||||||
newline ||= message.to_s !~ /( |\t)\Z/
|
newline ||= !message.to_s.match?(/( |\t)\Z/)
|
||||||
message = word_wrap(message) if newline.is_a?(Hash) && newline[:wrap]
|
message = word_wrap(message) if newline.is_a?(Hash) && newline[:wrap]
|
||||||
|
|
||||||
color = nil if color && !$stderr.tty?
|
color = nil if color && !$stderr.tty?
|
||||||
|
@ -190,7 +190,7 @@ class Gem::Command
|
|||||||
"Please specify at least one gem name (e.g. gem build GEMNAME)"
|
"Please specify at least one gem name (e.g. gem build GEMNAME)"
|
||||||
end
|
end
|
||||||
|
|
||||||
args.select {|arg| arg !~ /^-/ }
|
args.reject {|arg| arg.start_with?("-") }
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -89,7 +89,7 @@ class Gem::Platform
|
|||||||
when String then
|
when String then
|
||||||
arch = arch.split "-"
|
arch = arch.split "-"
|
||||||
|
|
||||||
if arch.length > 2 && arch.last !~ /\d+(\.\d+)?$/ # reassemble x86-linux-{libc}
|
if arch.length > 2 && !arch.last.match?(/\d+(\.\d+)?$/) # reassemble x86-linux-{libc}
|
||||||
extra = arch.pop
|
extra = arch.pop
|
||||||
arch.last << "-#{extra}"
|
arch.last << "-#{extra}"
|
||||||
end
|
end
|
||||||
@ -101,7 +101,7 @@ class Gem::Platform
|
|||||||
else cpu
|
else cpu
|
||||||
end
|
end
|
||||||
|
|
||||||
if arch.length == 2 && arch.last =~ /^\d+(\.\d+)?$/ # for command-line
|
if arch.length == 2 && arch.last.match?(/^\d+(\.\d+)?$/) # for command-line
|
||||||
@os, @version = arch
|
@os, @version = arch
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -227,7 +227,7 @@ class Gem::Source::Git < Gem::Source
|
|||||||
require_relative "../openssl"
|
require_relative "../openssl"
|
||||||
|
|
||||||
normalized =
|
normalized =
|
||||||
if @repository =~ %r{^\w+://(\w+@)?}
|
if @repository.match?(%r{^\w+://(\w+@)?})
|
||||||
uri = URI(@repository).normalize.to_s.sub %r{/$},""
|
uri = URI(@repository).normalize.to_s.sub %r{/$},""
|
||||||
uri.sub(/\A(\w+)/) { $1.downcase }
|
uri.sub(/\A(\w+)/) { $1.downcase }
|
||||||
else
|
else
|
||||||
|
@ -109,7 +109,7 @@ module Gem::Util
|
|||||||
# comes with a leading slash.
|
# comes with a leading slash.
|
||||||
|
|
||||||
def self.correct_for_windows_path(path)
|
def self.correct_for_windows_path(path)
|
||||||
if path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":"
|
if path[0].chr == "/" && path[1].chr.match?(/[a-z]/i) && path[2].chr == ":"
|
||||||
path[1..-1]
|
path[1..-1]
|
||||||
else
|
else
|
||||||
path
|
path
|
||||||
|
@ -582,7 +582,7 @@ class Gem::TestCase < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def in_path?(executable) # :nodoc:
|
def in_path?(executable) # :nodoc:
|
||||||
return true if %r{\A([A-Z]:|/)} =~ executable && File.exist?(executable)
|
return true if %r{\A([A-Z]:|/)}.match?(executable) && File.exist?(executable)
|
||||||
|
|
||||||
ENV["PATH"].split(File::PATH_SEPARATOR).any? do |directory|
|
ENV["PATH"].split(File::PATH_SEPARATOR).any? do |directory|
|
||||||
File.exist? File.join directory, executable
|
File.exist? File.join directory, executable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user