From: bert hubert Date: Thu, 5 Nov 2015 08:19:46 +0000 (+0100) Subject: prepare for removal of d_empty (but not there yet) X-Git-Tag: dnsdist-1.0.0-alpha1~239^2~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7822f514dc970246f01934d912c9bc4e77a1a3c8;p=pdns prepare for removal of d_empty (but not there yet) --- diff --git a/pdns/dnsname.cc b/pdns/dnsname.cc index 055b4d666..b039de179 100644 --- a/pdns/dnsname.cc +++ b/pdns/dnsname.cc @@ -80,9 +80,9 @@ void DNSName::packetParser(const char* pos, int len, int offset, bool uncompress std::string DNSName::toString(const std::string& separator, const bool trailing) const { - if (d_empty) + if (empty()) return ""; - if(d_storage.empty() && trailing) // I keep wondering if there is some deeper meaning to the need to do this + if(empty() && trailing) // I keep wondering if there is some deeper meaning to the need to do this return separator; std::string ret; for(const auto& s : getRawLabels()) { @@ -93,18 +93,14 @@ std::string DNSName::toString(const std::string& separator, const bool trailing) std::string DNSName::toDNSString() const { - if (d_empty) - return ""; + // if (empty()) + // return ""; string ret(d_storage.c_str(), d_storage.length()); ret.append(1,(char)0); return toLower(ret); // toLower or not toLower, that is the question // return ret; } -size_t DNSName::length() const { - return this->toString().length(); -} - /** * Get the length of the DNSName on the wire * @@ -117,7 +113,7 @@ size_t DNSName::wirelength() const { // are WE part of parent bool DNSName::isPartOf(const DNSName& parent) const { - if(parent.d_empty || d_empty) + if(parent.empty() || empty()) return false; if(parent.d_storage.empty()) return true; @@ -156,7 +152,7 @@ void DNSName::makeUsRelative(const DNSName& zone) DNSName DNSName::labelReverse() const { DNSName ret; - if (!d_empty) { + if (!empty()) { vector l=getRawLabels(); while(!l.empty()) { ret.appendRawLabel(l.back()); @@ -244,7 +240,7 @@ void DNSName::trimToLabels(unsigned int to) bool DNSName::operator==(const DNSName& rhs) const { - if(rhs.d_empty != d_empty || rhs.d_storage.size() != d_storage.size()) + if(rhs.empty() != empty() || rhs.d_storage.size() != d_storage.size()) return false; auto us = d_storage.crbegin(); diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index 92001fcc3..6bc80a9a5 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -27,7 +27,7 @@ class DNSName { public: - DNSName() : d_empty(true) {} //!< Don't constructs the root name + DNSName() : d_empty(true) {} //!< Constructs an *empty* DNSName, NOT the root! explicit DNSName(const char* p); //!< Constructs from a human formatted, escaped presentation explicit DNSName(const std::string& str) : DNSName(str.c_str()) {} //!< Constructs from a human formatted, escaped presentation DNSName(const char* p, int len, int offset, bool uncompress, uint16_t* qtype=0, uint16_t* qclass=0, unsigned int* consumed=0); //!< Construct from a DNS Packet, taking the first question if offset=12 @@ -48,7 +48,6 @@ public: DNSName labelReverse() const; bool isWildcard() const; unsigned int countLabels() const; - size_t length() const; // FIXME400 remove me? size_t wirelength() const; //!< Number of total bytes in the name bool empty() const { return d_empty; } bool isRoot() const { return !d_empty && d_storage.empty(); }