From 9849a6ce22bf737fed7e793bad588002bc1c116e Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 10 Apr 2014 12:19:44 +0400 Subject: [PATCH] Removed sstream from BitStream::toString() --- libuavcan/src/marshal/uc_bit_stream.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libuavcan/src/marshal/uc_bit_stream.cpp b/libuavcan/src/marshal/uc_bit_stream.cpp index 37211a8c5f..77464feb79 100644 --- a/libuavcan/src/marshal/uc_bit_stream.cpp +++ b/libuavcan/src/marshal/uc_bit_stream.cpp @@ -3,7 +3,7 @@ */ #include -#include +#include #include #include @@ -75,7 +75,9 @@ int BitStream::read(uint8_t* bytes, const int bitlen) std::string BitStream::toString() const { - std::ostringstream os; + std::string out; + out.reserve(128); + for (int offset = 0; true; offset++) { uint8_t byte = 0; @@ -85,16 +87,15 @@ std::string BitStream::toString() const } for (int i = 7; i >= 0; i--) // Most significant goes first { - os << !!(byte & (1 << i)); + out += (byte & (1 << i)) ? '1' : '0'; } - os << " "; + out += ' '; } - std::string output = os.str(); - if (output.length()) + if (out.length()) { - output.erase(output.length() - 1, 1); + out.erase(out.length() - 1, 1); } - return output; + return out; } }