[svn] commit: r959 - /branches/each-ds/src/lib/dns/cpp/hex.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Feb 25 05:17:35 UTC 2010


Author: jinmei
Date: Thu Feb 25 05:17:35 2010
New Revision: 959

Log:
simplification

Modified:
    branches/each-ds/src/lib/dns/cpp/hex.cc

Modified: branches/each-ds/src/lib/dns/cpp/hex.cc
==============================================================================
--- branches/each-ds/src/lib/dns/cpp/hex.cc (original)
+++ branches/each-ds/src/lib/dns/cpp/hex.cc Thu Feb 25 05:17:35 2010
@@ -43,13 +43,16 @@
     // calculate the resulting length.  it should be twice the
     // original data length
     size_t len = (binary.size() * 2);
-    std::ostringstream hex;
+    std::string s;
+    s.reserve(len);
 
     BOOST_FOREACH(uint8_t octet, binary) {
-        hex << hexdigits[octet >> 4] << hexdigits[octet & 0xf];
+        s.push_back(hexdigits[octet >> 4]);
+        s.push_back(hexdigits[octet & 0xf]);
     }
-    assert(len >= hex.str().length());
-    return (hex.str());
+    assert(len == s.length());
+
+    return (s);
 }
 
 void




More information about the bind10-changes mailing list