From: bert hubert Date: Fri, 27 Nov 2015 15:41:24 +0000 (+0100) Subject: make nonconst version of getTag() too which is faster X-Git-Tag: dnsdist-1.0.0-alpha1~180^2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=354ccf4e7e4a14561a94b5b1ecf6cbab6494f98f;p=thirdparty%2Fpdns.git make nonconst version of getTag() too which is faster --- diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index 9d47361c39..f95313111b 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -476,10 +476,8 @@ boilerplate_conv(TKEY, QType::TKEY, ) TKEYRecordContent::TKEYRecordContent() { d_othersize = 0; } // fix CID#1288932 -uint16_t DNSKEYRecordContent::getTag() const +static uint16_t makeTag(const std::string& data) { - DNSKEYRecordContent tmp(*this); - string data=tmp.serialize(DNSName()); // this can't be const for some reason const unsigned char* key=(const unsigned char*)data.c_str(); unsigned int keysize=data.length(); @@ -492,6 +490,18 @@ uint16_t DNSKEYRecordContent::getTag() const return ac & 0xFFFF; } +uint16_t DNSKEYRecordContent::getTag() const +{ + DNSKEYRecordContent tmp(*this); + return makeTag(tmp.serialize(DNSName())); // this can't be const for some reason +} + +uint16_t DNSKEYRecordContent::getTag() +{ + return makeTag(this->serialize(DNSName())); +} + + bool getEDNSOpts(const MOADNSParser& mdp, EDNSOpts* eo) { if(mdp.d_header.arcount && !mdp.d_answers.empty()) { diff --git a/pdns/dnsrecords.hh b/pdns/dnsrecords.hh index 2162747833..e5cf61d492 100644 --- a/pdns/dnsrecords.hh +++ b/pdns/dnsrecords.hh @@ -279,6 +279,7 @@ public: DNSKEYRecordContent(); includeboilerplate(DNSKEY) uint16_t getTag() const; + uint16_t getTag(); uint16_t d_flags; uint8_t d_protocol;