瀏覽代碼

reserving before encoding (#912)

Aswin Raj Kharel 5 年之前
父節點
當前提交
c58b00580e
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      httplib.h

+ 2 - 1
httplib.h

@@ -1612,7 +1612,8 @@ inline std::string encode_query_param(const std::string &value) {
 
 inline std::string encode_url(const std::string &s) {
   std::string result;
-
+  result.reserve(s.size());
+  
   for (size_t i = 0; s[i]; i++) {
     switch (s[i]) {
     case ' ': result += "%20"; break;