summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-23 23:57:30 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-23 23:57:30 +0000
commit214eecd391d6e2febb4d3c63566b1156abc7f7fc (patch)
treeceb892ab91fa0793ae61bd5a1b1eda58724915f2 /lib
parent376e57fee16018b7157c8875d43e4326e76b7c0b (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/resolv.rb4
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/resolv.rb b/lib/resolv.rb
index 51083134a3..a5a997a43d 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -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