Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: compiled/String.h

Issue 29384812: Issue 4127 - [emscripten] Convert subscription classes to C++ - Part 1 (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Removed unnecessary raw buffer Created April 10, 2017, 6:27 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | compiled/StringMap.h » ('j') | compiled/StringMap.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiled/String.h
===================================================================
--- a/compiled/String.h
+++ b/compiled/String.h
@@ -344,16 +344,28 @@ public:
return;
assert(source, u"Null buffer passed to OwnedString.append()"_str);
size_t oldLength = length();
grow(sourceLen);
std::memcpy(mBuf + oldLength, source, sizeof(value_type) * sourceLen);
}
+ void append(const char* source, size_type sourceLen)
+ {
+ if (!sourceLen)
+ return;
+
+ assert(source, u"Null buffer passed to OwnedString.append()"_str);
sergei 2017/04/12 12:04:31 I think it makes sense to put this assert before t
hub 2017/04/12 12:12:07 Not sure what the intent is but to me it looks rea
sergei 2017/04/12 12:14:40 Ah, sorry, misread it as `if (!source)...`. It's c
+ size_t oldLength = length();
+ grow(sourceLen);
+ for (size_t i = 0; i < sourceLen; i++)
+ mBuf[oldLength + i] = source[i];
+ }
+
void append(const String& str)
{
append(str.mBuf, str.length());
}
void append(value_type c)
{
append(&c, 1);
@@ -366,17 +378,17 @@ public:
bool negative = false;
if (num < 0)
{
negative = true;
num = -num;
}
size_type size = 0;
- for (int i = num; i; i /= 10)
+ for (T i = num; i; i /= 10)
size++;
size = (size ? size : 1);
size_type pos = length();
grow((negative ? 1 : 0) + size);
if (negative)
mBuf[pos++] = '-';
« no previous file with comments | « no previous file | compiled/StringMap.h » ('j') | compiled/StringMap.h » ('J')

Powered by Google App Engine
This is Rietveld