mirror of https://github.com/aria2/aria2
Use std::string::append instead of appending std::string() temporaries.
parent
9bb914b76e
commit
84bc2c7ae8
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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.",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue