CConnman::AddConnection locks m_nodes_mutex and counts existing connections of the requested type even for types that have no limit (ADDR_FETCH and FEELER), then discards the count. Move the count inside the max_connections != std::nullopt check so we only take the lock and walk the node list when there is a limit to enforce.
No behavior change: when max_connections is std::nullopt the old code computed a count it never used.