Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance optimization #1573

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/lib_json/json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ class OurFeatures {
bool rejectDupKeys_;
bool allowSpecialFloats_;
bool skipBom_;
bool skipEscapeString_;
size_t stackLimit_;
}; // OurFeatures

Expand Down Expand Up @@ -1438,8 +1439,10 @@ bool OurReader::readObject(Token& token) {
return true;
name.clear();
if (tokenName.type_ == tokenString) {
if (!decodeString(tokenName, name))
name = String(tokenName.start_ + 1, tokenName.end_ - 1);
/*if (!decodeString(tokenName, name))
return recoverFromError(tokenObjectEnd);
*/
} else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
Value numberName;
if (!decodeNumber(tokenName, numberName))
Expand Down Expand Up @@ -1650,6 +1653,10 @@ bool OurReader::decodeString(Token& token, String& decoded) {
decoded.reserve(static_cast<size_t>(token.end_ - token.start_ - 2));
Location current = token.start_ + 1; // skip '"'
Location end = token.end_ - 1; // do not include '"'
if (features_.skipEscapeString_) {
decoded = String(current, end);
return true;
}
while (current != end) {
Char c = *current++;
if (c == '"')
Expand Down Expand Up @@ -1895,6 +1902,7 @@ CharReader* CharReaderBuilder::newCharReader() const {
features.rejectDupKeys_ = settings_["rejectDupKeys"].asBool();
features.allowSpecialFloats_ = settings_["allowSpecialFloats"].asBool();
features.skipBom_ = settings_["skipBom"].asBool();
features.skipEscapeString_ = settings_["skipEscapeString"].asBool();
return new OurCharReader(collectComments, features);
}

Expand Down