Optimize rapidjson std lib usage

This commit is contained in:
Wojtek Figat
2023-05-09 16:39:13 +02:00
parent e03516e22e
commit e68807d574
4 changed files with 10 additions and 10 deletions

View File

@@ -214,7 +214,7 @@ public:
// Realloc process: allocate and copy memory, do not free original buffer.
if (void* newBuffer = Malloc(newSize)) {
if (originalSize)
std::memcpy(newBuffer, originalPtr, originalSize);
::memcpy(newBuffer, originalPtr, originalSize);
return newBuffer;
}
else

View File

@@ -1930,7 +1930,7 @@ private:
if (count) {
GenericValue* e = static_cast<GenericValue*>(allocator.Malloc(count * sizeof(GenericValue)));
SetElementsPointer(e);
std::memcpy(e, values, count * sizeof(GenericValue));
::memcpy(e, values, count * sizeof(GenericValue));
}
else
SetElementsPointer(0);
@@ -1943,7 +1943,7 @@ private:
if (count) {
Member* m = static_cast<Member*>(allocator.Malloc(count * sizeof(Member)));
SetMembersPointer(m);
std::memcpy(m, members, count * sizeof(Member));
::memcpy(m, members, count * sizeof(Member));
}
else
SetMembersPointer(0);
@@ -1970,7 +1970,7 @@ private:
str = static_cast<Ch *>(allocator.Malloc((s.length + 1) * sizeof(Ch)));
SetStringPointer(str);
}
std::memcpy(str, s, s.length * sizeof(Ch));
::memcpy(str, s, s.length * sizeof(Ch));
str[s.length] = '\0';
}
@@ -1994,7 +1994,7 @@ private:
const Ch* const str2 = rhs.GetString();
if(str1 == str2) { return true; } // fast path for constant string
return (std::memcmp(str1, str2, sizeof(Ch) * len1) == 0);
return (::memcmp(str1, str2, sizeof(Ch) * len1) == 0);
}
Data data_;

View File

@@ -34,7 +34,7 @@ public:
typedef uint64_t Type;
BigInteger(const BigInteger& rhs) : count_(rhs.count_) {
std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));
::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));
}
explicit BigInteger(uint64_t u) : count_(1) {
@@ -60,7 +60,7 @@ public:
{
if (this != &rhs) {
count_ = rhs.count_;
std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));
::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));
}
return *this;
}

View File

@@ -212,7 +212,7 @@ public:
GenericPointer r;
r.allocator_ = allocator;
Ch *p = r.CopyFromRaw(*this, 1, token.length + 1);
std::memcpy(p, token.name, (token.length + 1) * sizeof(Ch));
::memcpy(p, token.name, (token.length + 1) * sizeof(Ch));
r.tokens_[tokenCount_].name = p;
r.tokens_[tokenCount_].length = token.length;
r.tokens_[tokenCount_].index = token.index;
@@ -768,10 +768,10 @@ private:
tokens_ = static_cast<Token *>(allocator_->Malloc(tokenCount_ * sizeof(Token) + (nameBufferSize + extraNameBufferSize) * sizeof(Ch)));
nameBuffer_ = reinterpret_cast<Ch *>(tokens_ + tokenCount_);
if (rhs.tokenCount_ > 0) {
std::memcpy(tokens_, rhs.tokens_, rhs.tokenCount_ * sizeof(Token));
::memcpy(tokens_, rhs.tokens_, rhs.tokenCount_ * sizeof(Token));
}
if (nameBufferSize > 0) {
std::memcpy(nameBuffer_, rhs.nameBuffer_, nameBufferSize * sizeof(Ch));
::memcpy(nameBuffer_, rhs.nameBuffer_, nameBufferSize * sizeof(Ch));
}
// Adjust pointers to name buffer