Try to activate only inactive gems #227

Closed
voxik opened this Issue Dec 9, 2011 · 3 comments

Comments

Projects
None yet
3 participants
Contributor

voxik commented Dec 9, 2011

Hello,

Once the required file is not found by gem_original_require, RubyGems are going through all gems and tries to find which gem can contain the requested file. Unfortunately, it also goes through gems, which were already activated. However, for such gems, it makes no sense to look for some files to load, because their load paths are already available and the Ruby's require would be successful in that case. My simple patch [1] is trying to short-circuit the unnecessary search for files, and searches just the yet inactive gems. This patch should improve the RubyGems require performance, although I did not tested it. In theory, the more gems are activated, the faster should the require be.

[1] https://gist.github.com/1452549

Contributor

voxik commented Dec 9, 2011

Alternative implementation could be extension of the original find_by_path to accept optional parameter with :active, :inactive and :all flags and the search would be modified according to this flag.

zenspider was assigned Dec 12, 2011

Contributor

zenspider commented Dec 16, 2011

I like it, but it needs a test.

Contributor

voxik commented Dec 16, 2011

Hi, the test can be found here: https://gist.github.com/1486087

However, I am not sure if the test itself shouldn't be protected by something like "save_loaded_features" which is used in require tests.

evanphx closed this in abfb4b0 Oct 7, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment