blueloveTH 2 سال پیش
والد
کامیت
7182257413
2فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 1 2
      src/error.cpp
  2. 1 0
      src/str.cpp

+ 1 - 2
src/error.cpp

@@ -7,8 +7,7 @@ namespace pkpy{
         // Skip utf8 BOM if there is any.
         if (strncmp(source.data(), "\xEF\xBB\xBF", 3) == 0) index += 3;
         // Drop all '\r'
-        // SStream ss(source.size());
-        SStream ss;
+        SStream ss(source.size());
         while(index < source.size()){
             if(source[index] != '\r') ss << source[index];
             index++;

+ 1 - 0
src/str.cpp

@@ -437,6 +437,7 @@ int utf8len(unsigned char c, bool suppress){
 
     Str SStream::str(){
         // after this call, the buffer is no longer valid
+        buffer.reserve(buffer.size() + 1);  // allocate one more byte for '\0'
         return Str(buffer.detach());
     }