Skip to content

Commit

Permalink
[ruby/resolv] Simplify adding new entries
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu authored and matzbot committed Feb 25, 2024
1 parent 30b9986 commit 012a0b9
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/resolv.rb
Expand Up @@ -196,12 +196,8 @@ def lazy_initialize # :nodoc:
line.sub!(/#.*/, '')
addr, *hostnames = line.split(/\s+/)
next unless addr
@addr2name[addr] = [] unless @addr2name.include? addr
@addr2name[addr].concat(hostnames)
hostnames.each {|hostname|
@name2addr[hostname] = [] unless @name2addr.include? hostname
@name2addr[hostname] << addr
}
(@addr2name[addr] ||= []).concat(hostnames)
hostnames.each {|hostname| (@name2addr[hostname] ||= []) << addr}
}
}
@name2addr.each {|name, arr| arr.reverse!}
Expand Down

0 comments on commit 012a0b9

Please sign in to comment.