Skip to content

Commit

Permalink
Simplify adding new entries
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Feb 25, 2024
1 parent fa812d6 commit 081b8df
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/resolv.rb
Original file line number Diff line number Diff line change
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 081b8df

Please sign in to comment.