From d44e4e09aef4bda69a3eb86e3cf4045bed4afbe2 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Thu, 5 Nov 2015 09:19:46 +0100 Subject: [PATCH] prepare for removal of d_empty (but not there yet) --- pdns/dnsname.cc | 18 +++++++----------- pdns/dnsname.hh | 3 +-- 2 files changed, 8 insertions(+), 13 deletions(-) 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(); } -- 2.40.0