From: Remi Gacogne Date: Fri, 17 Jan 2020 14:15:16 +0000 (+0100) Subject: auth: Reduce the number of allocations in apiServerZones() X-Git-Tag: auth-4.3.0~5^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fe4563c05f7cf4d05d54ca2e7fde9d3d6407561;p=thirdparty%2Fpdns.git auth: Reduce the number of allocations in apiServerZones() (cherry picked from commit c8b929d9f1b17cb3ca73a309172d6929254bf91c) --- diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 6fb3637fa4..8a8c4336e9 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -325,8 +325,10 @@ static inline string makeBackendRecordContent(const QType& qtype, const string& static Json::object getZoneInfo(const DomainInfo& di, DNSSECKeeper* dk) { string zoneId = apiZoneNameToId(di.zone); vector masters; - for(const auto& m : di.masters) + masters.reserve(di.masters.size()); + for(const auto& m : di.masters) { masters.push_back(m.toStringWithPortExcept(53)); + } auto obj = Json::object { // id is the canonical lookup key, which doesn't actually match the name (in some cases) @@ -335,7 +337,7 @@ static Json::object getZoneInfo(const DomainInfo& di, DNSSECKeeper* dk) { { "name", di.zone.toString() }, { "kind", di.getKindString() }, { "account", di.account }, - { "masters", masters }, + { "masters", std::move(masters) }, { "serial", (double)di.serial }, { "notified_serial", (double)di.notified_serial }, { "last_check", (double)di.last_check } @@ -1727,6 +1729,7 @@ static void apiServerZones(HttpRequest* req, HttpResponse* resp) { } Json::array doc; + doc.reserve(domains.size()); for(const DomainInfo& di : domains) { doc.push_back(getZoneInfo(di, with_dnssec ? &dk : nullptr)); }