This simple refactoring PR aims to avoid duplicate lookups to mapLocalHost: 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()and dereference the returned iterator (for simple lookups), see https://www.cplusplus.com/reference/map/map/find/emplace()and use the returned <iterator, inserted> pair (for lookups where a new element should be inserted if the key isn't found), see https://www.cplusplus.com/reference/map/map/emplace/