mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
1 changed files with 1 additions and 3 deletions
|
@ -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…
Reference in a new issue