]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
SVCB: return const-refs for heavy kvs
authorPieter Lexis <pieter.lexis@powerdns.com>
Thu, 24 Sep 2020 13:21:23 +0000 (15:21 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Fri, 25 Sep 2020 10:28:14 +0000 (12:28 +0200)
pdns/svc-records.cc
pdns/svc-records.hh

index 994a11c36db1b21b2afb25e9fe396f5f6be91eef..c54241c1a457723243daaf12c524842daf1abe55 100644 (file)
@@ -138,7 +138,7 @@ bool SvcParam::operator<(const SvcParam& other) const {
   return this->d_key < other.getKey();
 }
 
-std::vector<ComboAddress> SvcParam::getIPHints() const {
+const std::vector<ComboAddress>& 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<std::string> SvcParam::getALPN() const {
+const std::vector<std::string>& 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::SvcParamKey> SvcParam::getMandatory() const {
+const std::set<SvcParam::SvcParamKey>& 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
+}
index 5488ade44f74b785544dc87e740ce07d44560ff7..2552ff4fb3b4a738f709264f17a8188d7e29cd8c 100644 (file)
@@ -78,11 +78,11 @@ class SvcParam {
   }
 
   uint16_t getPort() const;
-  std::vector<ComboAddress> getIPHints() const;
-  std::vector<std::string> getALPN() const;
-  std::set<SvcParamKey> getMandatory() const;
-  std::string getEchConfig() const;
-  std::string getValue() const;
+  const std::vector<ComboAddress>& getIPHints() const;
+  const std::vector<std::string>& getALPN() const;
+  const std::set<SvcParamKey>& getMandatory() const;
+  const std::string& getEchConfig() const;
+  const std::string& getValue() const;
 
   private:
     SvcParamKey d_key;