Avoid large reallocations in webserver's header response by d-a-v · Pull Request #8873 · esp8266/Arduino
at a glance, we have a bunch of typed pairs that generate multiple emplace_... for every sendHeader variant
I'd consider using perfect forward and a specific type we already have
using Pair = std::pair<String, String>; auto foo(Pair pair, bool condition) { if (condition) { foo(std::move(pair)); } else { bar(std::move(pair)); } } template <typename S1, typename S2> auto foo(S1&& name, S2&& value, bool condition) { foo(std::make_pair( String(std::forward<S1>(name)), String(std::forward<S2>(value)), condition); }