From 214eecd391d6e2febb4d3c63566b1156abc7f7fc Mon Sep 17 00:00:00 2001 From: normal Date: Wed, 23 Nov 2016 23:57:30 +0000 Subject: 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 --- lib/resolv.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/resolv.rb') 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 -- cgit v1.2.3