From: Pieter Lexis Date: Thu, 24 Sep 2020 13:21:23 +0000 (+0200) Subject: SVCB: return const-refs for heavy kvs X-Git-Tag: auth-4.4.0-alpha1~2^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5cfcf78565e4d0938ff7b44acc03e6e440fcf87;p=thirdparty%2Fpdns.git SVCB: return const-refs for heavy kvs --- diff --git a/pdns/svc-records.cc b/pdns/svc-records.cc index 994a11c36d..c54241c1a4 100644 --- a/pdns/svc-records.cc +++ b/pdns/svc-records.cc @@ -138,7 +138,7 @@ bool SvcParam::operator<(const SvcParam& other) const { return this->d_key < other.getKey(); } -std::vector SvcParam::getIPHints() const { +const std::vector& SvcParam::getIPHints() const { if (d_key != SvcParamKey::ipv6hint && d_key != SvcParamKey::ipv4hint) { throw std::invalid_argument("getIPHints called for non-IP address key '" + keyToString(d_key) + "'"); } @@ -152,30 +152,30 @@ uint16_t SvcParam::getPort() const { return d_port; } -std::vector SvcParam::getALPN() const { +const std::vector& SvcParam::getALPN() const { if (d_key != SvcParam::alpn) { throw std::invalid_argument("getALPN called for non-alpn key '" + keyToString(d_key) + "'"); } return d_alpn; } -std::set SvcParam::getMandatory() const { +const std::set& SvcParam::getMandatory() const { if (d_key != SvcParam::mandatory) { throw std::invalid_argument("getMandatory called for non-mandatory key '" + keyToString(d_key) + "'"); } return d_mandatory; } -std::string SvcParam::getEchConfig() const { +const std::string& SvcParam::getEchConfig() const { if (d_key != SvcParam::echconfig) { throw std::invalid_argument("getEchConfig called for non-echconfig key '" + keyToString(d_key) + "'"); } return d_echconfig; } -std::string SvcParam::getValue() const { +const std::string& SvcParam::getValue() const { if (d_key < 7) { throw std::invalid_argument("getValue called for non-single value key '" + keyToString(d_key) + "'"); } return d_value; -} \ No newline at end of file +} diff --git a/pdns/svc-records.hh b/pdns/svc-records.hh index 5488ade44f..2552ff4fb3 100644 --- a/pdns/svc-records.hh +++ b/pdns/svc-records.hh @@ -78,11 +78,11 @@ class SvcParam { } uint16_t getPort() const; - std::vector getIPHints() const; - std::vector getALPN() const; - std::set getMandatory() const; - std::string getEchConfig() const; - std::string getValue() const; + const std::vector& getIPHints() const; + const std::vector& getALPN() const; + const std::set& getMandatory() const; + const std::string& getEchConfig() const; + const std::string& getValue() const; private: SvcParamKey d_key;