Просмотр исходного кода

Improved performance of read_content_without_length

yhirose 6 лет назад
Родитель
Сommit
bde3fd9f78
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      httplib.h

+ 3 - 3
httplib.h

@@ -896,15 +896,15 @@ inline void skip_content_with_length(Stream &strm, size_t len) {
 }
 }
 
 
 inline bool read_content_without_length(Stream &strm, std::string &out) {
 inline bool read_content_without_length(Stream &strm, std::string &out) {
+  char buf[BUFSIZ];
   for (;;) {
   for (;;) {
-    char byte;
-    auto n = strm.read(&byte, 1);
+    auto n = strm.read(buf, BUFSIZ);
     if (n < 0) {
     if (n < 0) {
       return false;
       return false;
     } else if (n == 0) {
     } else if (n == 0) {
       return true;
       return true;
     }
     }
-    out += byte;
+    out.append(buf, n);
   }
   }
 
 
   return true;
   return true;