Replace `gsub` with `tr`
Using `tr` is faster than `gsub` when replacing a single character in a string with another single character
MODIFY
lib/mruby/gem.rb
lib/mruby/gem.rb
@@ -170,7 +170,7 @@ module MRuby
end
def funcname
- @funcname ||= @name.gsub('-', '_')
+ @funcname ||= @name.tr('-', '_')
end
def compilers

MODIFY
test/bintest.rb
test/bintest.rb
@@ -44,7 +44,7 @@ ARGV.each do |gem|
case RbConfig::CONFIG['host_os']
when /mswin(?!ce)|mingw|bccwin/
- gem = gem.gsub('\\', '/')
+ gem = gem.tr('\\', '/')
end
Dir["#{gem}/bintest/**/*.rb"].each do |file|

Replace `gsub` with `tr`

Using `tr` is faster than `gsub` when replacing a single character in a string with another single character