resolv: use safe navigation operator to avoid extra hash lookups
@addr2name is a private Hash and never changes its default_proc, so only pay the hash lookup cost once; we know missing entries in the hash will be nil. * lib/resolv.rb (each_name): use safe navigation operator git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
376e57fee1
commit
214eecd391
@ -264,9 +264,7 @@ class Resolv
|
||||
|
||||
def each_name(address, &proc)
|
||||
lazy_initialize
|
||||
if @addr2name.include?(address)
|
||||
@addr2name[address].each(&proc)
|
||||
end
|
||||
@addr2name[address]&.each(&proc)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user