diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-23 23:57:30 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-23 23:57:30 +0000 |
commit | f4a36fd4c4f1eabcdc1084ecb8f114f56ccdfb6a (patch) | |
tree | ceb892ab91fa0793ae61bd5a1b1eda58724915f2 /lib | |
parent | 23446e637401fe9910ab8abfcb252a433ef7c995 (diff) | |
download | ruby-f4a36fd4c4f1eabcdc1084ecb8f114f56ccdfb6a.tar.gz |
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.rb | 4 |
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 |