Browse Source

Improved performance of read_content_without_length

yhirose 6 years ago
parent
commit
bde3fd9f78
1 changed files with 3 additions and 3 deletions
  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;