OLD | NEW |
1 #pragma once | 1 #pragma once |
2 | 2 |
3 #include <cstddef> | 3 #include <cstddef> |
4 #include <cstring> | 4 #include <cstring> |
5 #include <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include <emscripten.h> | 7 #include <emscripten.h> |
8 | 8 |
9 #include "debug.h" | 9 #include "debug.h" |
10 | 10 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 { | 324 { |
325 if (!sourceLen) | 325 if (!sourceLen) |
326 return; | 326 return; |
327 | 327 |
328 assert(source, u"Null buffer passed to OwnedString.append()"_str); | 328 assert(source, u"Null buffer passed to OwnedString.append()"_str); |
329 size_t oldLength = length(); | 329 size_t oldLength = length(); |
330 grow(sourceLen); | 330 grow(sourceLen); |
331 std::memcpy(mBuf + oldLength, source, sizeof(value_type) * sourceLen); | 331 std::memcpy(mBuf + oldLength, source, sizeof(value_type) * sourceLen); |
332 } | 332 } |
333 | 333 |
| 334 void append(const char* source, size_type sourceLen) |
| 335 { |
| 336 if (!sourceLen) |
| 337 return; |
| 338 |
| 339 assert(source, u"Null buffer passed to OwnedString.append()"_str); |
| 340 size_t oldLength = length(); |
| 341 grow(sourceLen); |
| 342 for (size_t i = 0; i < sourceLen; i++) |
| 343 mBuf[oldLength + i] = source[i]; |
| 344 } |
| 345 |
334 void append(const String& str) | 346 void append(const String& str) |
335 { | 347 { |
336 append(str.mBuf, str.length()); | 348 append(str.mBuf, str.length()); |
337 } | 349 } |
338 | 350 |
339 void append(value_type c) | 351 void append(value_type c) |
340 { | 352 { |
341 append(&c, 1); | 353 append(&c, 1); |
342 } | 354 } |
343 }; | 355 }; |
OLD | NEW |