Browse files

Add simple cache to Bundler.load_gemspec

In some projects, for example those with 10s of local gemspecs, use of
`git ls-files` for spec.files, or specs requiring significant source
to get at a spec.version; this change to cache load_gemspec results in
notable performance gains.

The cache also avoids loading these same gemspecs repeatedly with
different LOAD_PATH values.
  • Loading branch information...
1 parent 691c8ac commit 3d4163a05d7dc7a33095e6567933bac41225d06d @dekellum committed with indirect Jan 19, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/bundler.rb
@@ -270,6 +270,11 @@ def read_file(file)
def load_gemspec(file)
+ @gemspec_cache ||= {}
+ @gemspec_cache[File.expand_path(file)] ||= load_gemspec_uncached(file)
+ end
+ def load_gemspec_uncached(file)
path =
# Eval the gemspec from its parent directory
Dir.chdir(path.dirname.to_s) do

0 comments on commit 3d4163a

Please sign in to comment.