You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2014/08/07 00:32:51 UTC

[2/2] git commit: Clean up a bit, remove unneeded int temporary.

Clean up a bit, remove unneeded int temporary.


Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/5dee6c54
Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/5dee6c54
Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/5dee6c54

Branch: refs/heads/3.8.x
Commit: 5dee6c54a8a379c1217494f20b501f742551f41a
Parents: 857c912
Author: Timothy Bish <ta...@gmail.com>
Authored: Wed Aug 6 18:20:23 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Wed Aug 6 18:20:57 2014 -0400

----------------------------------------------------------------------
 activemq-cpp/src/main/decaf/lang/Integer.cpp | 28 +++++++----------------
 1 file changed, 8 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/5dee6c54/activemq-cpp/src/main/decaf/lang/Integer.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Integer.cpp b/activemq-cpp/src/main/decaf/lang/Integer.cpp
index fadf6d0..cedb6f0 100644
--- a/activemq-cpp/src/main/decaf/lang/Integer.cpp
+++ b/activemq-cpp/src/main/decaf/lang/Integer.cpp
@@ -136,10 +136,7 @@ std::string Integer::toString(int value, int radix) {
         count++;
     }
 
-    // Save length and allocate a new buffer for the string, add one
-    // more for the null character.
-    int length = count;
-    std::vector<char> buffer(length);
+    std::vector<char> buffer(count);
 
     do {
         int ch = 0 - (j % radix);
@@ -155,7 +152,7 @@ std::string Integer::toString(int value, int radix) {
         buffer[0] = '-';
     }
 
-    return std::string(&buffer[0], length);
+    return std::string(&buffer[0], buffer.size());
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -172,17 +169,14 @@ std::string Integer::toBinaryString(int value) {
         }
     }
 
-    // Save length and allocate a new buffer for the string, add one
-    // more for the null character.
-    int length = count;
-    std::vector<char> buffer(length);
+    std::vector<char> buffer(count);
 
     do {
         buffer[--count] = (char) ((value & 1) + '0');
         value >>= 1;
     } while (count > 0);
 
-    return std::string(&buffer[0], length);
+    return std::string(&buffer[0], buffer.size());
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -199,17 +193,14 @@ std::string Integer::toOctalString(int value) {
         }
     }
 
-    // Save length and allocate a new buffer for the string, add one
-    // more for the null character.
-    int length = count;
-    std::vector<char> buffer(length);
+    std::vector<char> buffer(count);
 
     do {
         buffer[--count] = (char) ((uvalue & 7) + '0');
         uvalue >>= 3;
     } while (count > 0);
 
-    return std::string(&buffer[0], length);
+    return std::string(&buffer[0], buffer.size());
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -226,10 +217,7 @@ std::string Integer::toHexString(int value) {
         }
     }
 
-    // Save length and allocate a new buffer for the string, add one
-    // more for the null character.
-    int length = count;
-    std::vector<char> buffer(length);
+    std::vector<char> buffer(count);
 
     do {
         int t = value & 15;
@@ -242,7 +230,7 @@ std::string Integer::toHexString(int value) {
         value >>= 4;
     } while (count > 0);
 
-    return std::string(&buffer[0], length);
+    return std::string(&buffer[0], buffer.size());
 }
 
 ////////////////////////////////////////////////////////////////////////////////