From 5fd12c42e7911fe5a07db3f92167983bd6e78008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Fri, 3 Nov 2023 17:03:09 +0100 Subject: [PATCH] Cache `Gem.default_dir` RubyGems do internally the same \[[1]\]. This should help with: 1) Performance (not tested) 2) Running RubyGems test suite (main motivation), which actually overrides the `@default_dir` \[[2]\] to be able to place test content into dedicated directory. [1]: https://github.com/rubygems/rubygems/blob/f8e87eba76526d2609d543eb7774711d345edc61/lib/rubygems/defaults.rb#L38 [2]: https://github.com/rubygems/rubygems/blob/f8e87eba76526d2609d543eb7774711d345edc61/test/rubygems/helper.rb#L372 --- operating_system.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operating_system.rb b/operating_system.rb index d95b303..f38aa5d 100644 --- a/operating_system.rb +++ b/operating_system.rb @@ -113,7 +113,7 @@ module Gem # RubyGems default overrides. def default_dir - Gem.default_dirs[:system][:gem_dir] + @default_dir ||= Gem.default_dirs[:system][:gem_dir] end def default_path