[前][次][番号順一覧][スレッド一覧]

ruby-changes:61107

From: David <ko1@a...>
Date: Fri, 8 May 2020 14:14:21 +0900 (JST)
Subject: [ruby-changes:61107] 0d7e0eb2fa (master): [rubygems/rubygems] Prefer `tr` to `gsub` when replacing path separators

https://git.ruby-lang.org/ruby.git/commit/?id=0d7e0eb2fa

From 0d7e0eb2faa282e0c15faa60c62992ca5452e228 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Sat, 2 May 2020 12:37:57 +0200
Subject: [rubygems/rubygems] Prefer `tr` to `gsub` when replacing path
 separators

This is not detected by the `Performance/StringReplacement` cop, I guess
because of using constants. But still seems like a good change.

Co-authored-by: MSP-Greg <MSP-Greg@u...>

https://github.com/rubygems/rubygems/commit/f862103133

diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 343037e..cf67685 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -709,7 +709,7 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L709
     return if self.class.path_warning
 
     user_bin_dir = @bin_dir || Gem.bindir(gem_home)
-    user_bin_dir = user_bin_dir.gsub(File::SEPARATOR, File::ALT_SEPARATOR) if
+    user_bin_dir = user_bin_dir.tr(File::SEPARATOR, File::ALT_SEPARATOR) if
       File::ALT_SEPARATOR
 
     path = ENV['PATH']
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]