refactor: net: avoid duplicate map lookups to mapLocalHost
Summary:
Instead of calling count() (to first find out whether a key is in the map) and then operator[] (to get the value to the passed key, or default-construct one if not found), use either find() or emplace()`
This is a backport of core#22896
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D13350