]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2124] some suggested changes:
authorJINMEI Tatuya <jinmei@isc.org>
Fri, 27 Jul 2012 07:18:32 +0000 (00:18 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Fri, 27 Jul 2012 07:18:32 +0000 (00:18 -0700)
- use !empty() instead of size() > 0.  for vectors there should be
  essentially no difference, but for other type of containers the former
  is generally better, and so I believe it's better to always follow that
  convention.
- constify

src/lib/dns/rdata/generic/sshfp_44.cc

index 7489f404f20a40bdc01f9370f2e0e9cb69e82d49..8358c74943c9f5b3cdf1ab42e9f1b07ca263b81b 100644 (file)
@@ -109,7 +109,7 @@ SSHFP::toWire(OutputBuffer& buffer) const {
     buffer.writeUint8(algorithm_);
     buffer.writeUint8(fingerprint_type_);
 
-    if (fingerprint_.size() > 0) {
+    if (!fingerprint_.empty()) {
         buffer.writeData(&fingerprint_[0], fingerprint_.size());
     }
 }
@@ -119,7 +119,7 @@ SSHFP::toWire(AbstractMessageRenderer& renderer) const {
     renderer.writeUint8(algorithm_);
     renderer.writeUint8(fingerprint_type_);
 
-    if (fingerprint_.size() > 0) {
+    if (!fingerprint_.empty()) {
         renderer.writeData(&fingerprint_[0], fingerprint_.size());
     }
 }
@@ -150,14 +150,15 @@ SSHFP::compare(const Rdata& other) const {
         return (1);
     }
 
-    size_t this_len = fingerprint_.size();
-    size_t other_len = other_sshfp.fingerprint_.size();
-    size_t cmplen = min(this_len, other_len);
+    const size_t this_len = fingerprint_.size();
+    const size_t other_len = other_sshfp.fingerprint_.size();
+    const size_t cmplen = min(this_len, other_len);
     if (cmplen == 0) {
         return ((this_len == other_len)
                 ? 0 : (this_len < other_len) ? -1 : 1);
     }
-    int cmp = memcmp(&fingerprint_[0], &other_sshfp.fingerprint_[0], cmplen);
+    const int cmp = memcmp(&fingerprint_[0], &other_sshfp.fingerprint_[0],
+                           cmplen);
     if (cmp != 0) {
         return (cmp);
     } else {