diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2020-05-19 14:00:00 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-06-05 07:32:42 +0900 |
commit | a18e81d797135de6e143a600e4f4d2b00ab23bf9 (patch) | |
tree | aaf319c30c0b65fa0f2718b445cc7efe33736210 /lib/rubygems.rb | |
parent | 8c8364c84e53303baf3828fd5266cb5aec54c582 (diff) | |
download | ruby-a18e81d797135de6e143a600e4f4d2b00ab23bf9.tar.gz |
[rubygems/rubygems] Fix performance regression in `require`
Our check for `-I` paths should not go through all activated gems.
https://github.com/rubygems/rubygems/commit/00d98eb8a3
Diffstat (limited to 'lib/rubygems.rb')
-rw-r--r-- | lib/rubygems.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb index ef744c40ba..9bf1c63a3e 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -594,9 +594,19 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} end ## + # The number of paths in the `$LOAD_PATH` from activated gems. Used to + # prioritize `-I` and `ENV['RUBYLIB`]` entries during `require`. + + def self.activated_gem_paths + @activated_gem_paths ||= 0 + end + + ## # Add a list of paths to the $LOAD_PATH at the proper place. def self.add_to_load_path(*paths) + @activated_gem_paths = activated_gem_paths + paths.size + insert_index = load_path_insert_index if insert_index |