Forráskód Böngészése

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

Tatsuhiro Tsujikawa 14 éve
szülő
commit
84bc2c7ae8

+ 1 - 1
src/ExpatMetalinkProcessor.cc

@@ -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

+ 1 - 1
src/ExpatXmlRpcRequestProcessor.cc

@@ -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

+ 1 - 1
src/XML2SAXMetalinkProcessor.cc

@@ -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

+ 1 - 1
src/Xml2XmlRpcRequestProcessor.cc

@@ -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

+ 4 - 4
src/base32.cc

@@ -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;
 }

+ 1 - 1
src/bittorrent_helper.cc

@@ -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);
   }

+ 2 - 2
src/json.cc

@@ -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.",

+ 1 - 1
src/uri.cc

@@ -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;
   }
 }