Skip to content

Commit 54032f3

Browse files
authored
Merge pull request #6923 from technicalpickles/bundler-settings-bracket-operator-performance
(Further) Improve Bundler::Settings#[] performance and memory usage
2 parents c44fe8e + 75ffa8e commit 54032f3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

bundler/lib/bundler/settings.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ def initialize(root = nil)
102102
def [](name)
103103
key = key_for(name)
104104

105-
values = configs.values
106-
values.map! {|config| config[key] }
107-
values.compact!
108-
value = values.first
105+
value = nil
106+
configs.each do |_, config|
107+
value = config[key]
108+
next if value.nil?
109+
break
110+
end
109111

110112
converted_value(value, name)
111113
end
@@ -316,7 +318,7 @@ def key_for(key)
316318
private
317319

318320
def configs
319-
{
321+
@configs ||= {
320322
:temporary => @temporary,
321323
:local => @local_config,
322324
:env => @env_config,

0 commit comments

Comments
 (0)