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 6783436 commit f8b50662ddec80afb0b321b9f7fdde01b640c6a0 @dekellum committed Jan 19, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/bundler.rb
@@ -230,6 +230,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 f8b5066

Please sign in to comment.