Use std::string::append instead of appending std::string() temporaries.

pull/2/head
Tatsuhiro Tsujikawa 2011-11-03 18:56:47 +09:00
parent 9bb914b76e
commit 84bc2c7ae8
8 changed files with 12 additions and 12 deletions

View File

@ -140,7 +140,7 @@ void mlCharacters(void* userData, const char* ch, int len)
{
SessionData* sd = reinterpret_cast<SessionData*>(userData);
if(sd->stm_->needsCharactersBuffering()) {
sd->charactersStack_.front() += std::string(&ch[0], &ch[len]);
sd->charactersStack_.front().append(&ch[0], &ch[len]);
}
}
} // namespace

View File

@ -99,7 +99,7 @@ void mlCharacters(void* userData, const char* ch, int len)
{
SessionData* sd = reinterpret_cast<SessionData*>(userData);
if(sd->stm_->needsCharactersBuffering()) {
sd->charactersStack_.top() += std::string(&ch[0], &ch[len]);
sd->charactersStack_.top().append(&ch[0], &ch[len]);
}
}
} // namespace

View File

@ -137,7 +137,7 @@ void mlCharacters(void* userData, const xmlChar* ch, int len)
{
SessionData* sd = reinterpret_cast<SessionData*>(userData);
if(sd->stm_->needsCharactersBuffering()) {
sd->charactersStack_.front() += std::string(&ch[0], &ch[len]);
sd->charactersStack_.front().append(&ch[0], &ch[len]);
}
}
} // namespace

View File

@ -101,7 +101,7 @@ void mlCharacters(void* userData, const xmlChar* ch, int len)
{
SessionData* sd = reinterpret_cast<SessionData*>(userData);
if(sd->stm_->needsCharactersBuffering()) {
sd->charactersStack_.top() += std::string(&ch[0], &ch[len]);
sd->charactersStack_.top().append(&ch[0], &ch[len]);
}
}
} // namespace

View File

@ -63,7 +63,7 @@ std::string encode(const std::string& src)
temp[7-j] = B32TABLE[buf&0x1fu];
buf >>= 5;
}
ret += std::string(&temp[0], &temp[8]);
ret.append(&temp[0], &temp[8]);
count = 0;
buf = 0;
}
@ -87,9 +87,9 @@ std::string encode(const std::string& src)
temp[r-1-j] = B32TABLE[buf&0x1fu];
buf >>= 5;
}
ret += std::string(&temp[0], &temp[r]);
ret.append(&temp[0], &temp[r]);
if(r) {
ret += std::string(8-r, '=');
ret.append(8-r, '=');
}
return ret;
}
@ -126,7 +126,7 @@ std::string decode(const std::string& src)
bits = bits/8*8;
buf = hton64(buf);
char* p = reinterpret_cast<char*>(&buf);
ret += std::string(&p[(64-bits)/8], &p[8]);
ret.append(&p[(64-bits)/8], &p[8]);
}
return ret;
}

View File

@ -663,7 +663,7 @@ std::string generatePeerId(const std::string& peerIdPrefix)
int len = 20-peerIdPrefix.size();
if(len > 0) {
util::generateRandomData(buf, len);
peerId += std::string(&buf[0], &buf[len]);
peerId.append(&buf[0], &buf[len]);
} if(peerId.size() > 20) {
peerId.erase(20);
}

View File

@ -156,7 +156,7 @@ decodeString
break;
}
if(*first == '\\') {
s += std::string(offset, first);
s.append(offset, first);
++first;
checkEof(first, last);
if(*first == 'u') {
@ -235,7 +235,7 @@ decodeString
}
checkEof(first, last);
if(std::distance(offset, first) > 0) {
s += std::string(offset, first);
s.append(offset, first);
}
if(!util::isUtf8(s)) {
throw DL_ABORT_EX2("JSON decoding failed: Non UTF-8 string.",

View File

@ -332,7 +332,7 @@ std::string joinUri(const std::string& baseUri, const std::string& uri)
!util::endsWith(res, "/")) {
res += "/";
}
res += std::string(end, qend);
res.append(end, qend);
return res;
}
}