From: JINMEI Tatuya Date: Fri, 20 Jul 2012 07:58:05 +0000 (-0700) Subject: [2091a] cleanup: constify; brace; C++ cast X-Git-Tag: trac2351_base~157^2~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b8eb94ff7d736acaa5e8a1f09044617e66958a5d;p=thirdparty%2Fkea.git [2091a] cleanup: constify; brace; C++ cast --- diff --git a/src/lib/dns/labelsequence.cc b/src/lib/dns/labelsequence.cc index 7627571a97..58cf42ac5f 100644 --- a/src/lib/dns/labelsequence.cc +++ b/src/lib/dns/labelsequence.cc @@ -110,7 +110,8 @@ LabelSequence::equals(const LabelSequence& other, bool case_sensitive) const { NameComparisonResult LabelSequence::compare(const LabelSequence& other, - bool case_sensitive) const { + bool case_sensitive) const +{ if (isAbsolute() ^ other.isAbsolute()) { return (NameComparisonResult(0, 0, NameComparisonResult::NONE)); } @@ -122,7 +123,7 @@ LabelSequence::compare(const LabelSequence& other, unsigned int nlabels = 0; int l1 = last_label_ - first_label_; int l2 = other.last_label_ - other.first_label_; - int ldiff = (int)l1 - (int)l2; + const int ldiff = static_cast(l1) - static_cast(l2); unsigned int l = (ldiff < 0) ? l1 : l2; while (l > 0) { @@ -138,19 +139,21 @@ LabelSequence::compare(const LabelSequence& other, // bitstring labels. assert(count1 <= Name::MAX_LABELLEN && count2 <= Name::MAX_LABELLEN); - int cdiff = (int)count1 - (int)count2; + const int cdiff = static_cast(count1) - static_cast(count2); unsigned int count = (cdiff < 0) ? count1 : count2; while (count > 0) { - uint8_t label1 = data_[pos1]; - uint8_t label2 = other.data_[pos2]; + const uint8_t label1 = data_[pos1]; + const uint8_t label2 = other.data_[pos2]; int chdiff; if (case_sensitive) { - chdiff = (int)label1 - (int)label2; + chdiff = static_cast(label1) - static_cast(label2); } else { - chdiff = (int)isc::dns::name::internal::maptolower[label1] - - (int)isc::dns::name::internal::maptolower[label2]; + chdiff = static_cast( + isc::dns::name::internal::maptolower[label1]) - + static_cast( + isc::dns::name::internal::maptolower[label2]); } if (chdiff != 0) { diff --git a/src/lib/dns/labelsequence.h b/src/lib/dns/labelsequence.h index d6f02c91ca..0275dfada3 100644 --- a/src/lib/dns/labelsequence.h +++ b/src/lib/dns/labelsequence.h @@ -40,7 +40,6 @@ namespace dns { /// LabelSequences can be compared to other LabelSequences, and their /// data can be requested (which then points to part of the original /// data of the original Name object). -/// class LabelSequence { // Name calls the private toText(bool) method of LabelSequence. friend std::string Name::toText(bool) const; @@ -281,3 +280,7 @@ operator<<(std::ostream& os, const LabelSequence& label_sequence); } // end namespace isc #endif + +// Local Variables: +// mode: c++ +// End: