mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-05-18 19:37:35 +02:00
Merge pull request #599 from pavel-pimenov/fix-v815
Fix V815:Decreased performance
This commit is contained in:
commit
559b4416e6
@ -137,7 +137,7 @@ bool Reader::parse(const char* beginDoc,
|
|||||||
current_ = begin_;
|
current_ = begin_;
|
||||||
lastValueEnd_ = 0;
|
lastValueEnd_ = 0;
|
||||||
lastValue_ = 0;
|
lastValue_ = 0;
|
||||||
commentsBefore_ = "";
|
commentsBefore_.clear();
|
||||||
errors_.clear();
|
errors_.clear();
|
||||||
while (!nodes_.empty())
|
while (!nodes_.empty())
|
||||||
nodes_.pop();
|
nodes_.pop();
|
||||||
@ -176,7 +176,7 @@ bool Reader::readValue() {
|
|||||||
|
|
||||||
if (collectComments_ && !commentsBefore_.empty()) {
|
if (collectComments_ && !commentsBefore_.empty()) {
|
||||||
currentValue().setComment(commentsBefore_, commentBefore);
|
currentValue().setComment(commentsBefore_, commentBefore);
|
||||||
commentsBefore_ = "";
|
commentsBefore_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (token.type_) {
|
switch (token.type_) {
|
||||||
@ -474,7 +474,7 @@ bool Reader::readObject(Token& tokenStart) {
|
|||||||
break;
|
break;
|
||||||
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
|
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
|
||||||
return true;
|
return true;
|
||||||
name = "";
|
name.clear();
|
||||||
if (tokenName.type_ == tokenString) {
|
if (tokenName.type_ == tokenString) {
|
||||||
if (!decodeString(tokenName, name))
|
if (!decodeString(tokenName, name))
|
||||||
return recoverFromError(tokenObjectEnd);
|
return recoverFromError(tokenObjectEnd);
|
||||||
@ -1056,7 +1056,7 @@ bool OurReader::parse(const char* beginDoc,
|
|||||||
current_ = begin_;
|
current_ = begin_;
|
||||||
lastValueEnd_ = 0;
|
lastValueEnd_ = 0;
|
||||||
lastValue_ = 0;
|
lastValue_ = 0;
|
||||||
commentsBefore_ = "";
|
commentsBefore_.clear();
|
||||||
errors_.clear();
|
errors_.clear();
|
||||||
while (!nodes_.empty())
|
while (!nodes_.empty())
|
||||||
nodes_.pop();
|
nodes_.pop();
|
||||||
@ -1098,7 +1098,7 @@ bool OurReader::readValue() {
|
|||||||
|
|
||||||
if (collectComments_ && !commentsBefore_.empty()) {
|
if (collectComments_ && !commentsBefore_.empty()) {
|
||||||
currentValue().setComment(commentsBefore_, commentBefore);
|
currentValue().setComment(commentsBefore_, commentBefore);
|
||||||
commentsBefore_ = "";
|
commentsBefore_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (token.type_) {
|
switch (token.type_) {
|
||||||
@ -1447,7 +1447,7 @@ bool OurReader::readObject(Token& tokenStart) {
|
|||||||
break;
|
break;
|
||||||
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
|
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
|
||||||
return true;
|
return true;
|
||||||
name = "";
|
name.clear();
|
||||||
if (tokenName.type_ == tokenString) {
|
if (tokenName.type_ == tokenString) {
|
||||||
if (!decodeString(tokenName, name))
|
if (!decodeString(tokenName, name))
|
||||||
return recoverFromError(tokenObjectEnd);
|
return recoverFromError(tokenObjectEnd);
|
||||||
|
@ -880,7 +880,7 @@ bool Value::isConvertibleTo(ValueType other) const {
|
|||||||
case nullValue:
|
case nullValue:
|
||||||
return (isNumeric() && asDouble() == 0.0) ||
|
return (isNumeric() && asDouble() == 0.0) ||
|
||||||
(type_ == booleanValue && value_.bool_ == false) ||
|
(type_ == booleanValue && value_.bool_ == false) ||
|
||||||
(type_ == stringValue && asString() == "") ||
|
(type_ == stringValue && asString().empty()) ||
|
||||||
(type_ == arrayValue && value_.map_->size() == 0) ||
|
(type_ == arrayValue && value_.map_->size() == 0) ||
|
||||||
(type_ == objectValue && value_.map_->size() == 0) ||
|
(type_ == objectValue && value_.map_->size() == 0) ||
|
||||||
type_ == nullValue;
|
type_ == nullValue;
|
||||||
@ -1506,6 +1506,7 @@ Path::Path(const JSONCPP_STRING& path,
|
|||||||
const PathArgument& a4,
|
const PathArgument& a4,
|
||||||
const PathArgument& a5) {
|
const PathArgument& a5) {
|
||||||
InArgs in;
|
InArgs in;
|
||||||
|
in.reserve(5);
|
||||||
in.push_back(&a1);
|
in.push_back(&a1);
|
||||||
in.push_back(&a2);
|
in.push_back(&a2);
|
||||||
in.push_back(&a3);
|
in.push_back(&a3);
|
||||||
|
@ -335,7 +335,7 @@ void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
|
|||||||
void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
|
void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
|
||||||
|
|
||||||
JSONCPP_STRING FastWriter::write(const Value& root) {
|
JSONCPP_STRING FastWriter::write(const Value& root) {
|
||||||
document_ = "";
|
document_.clear();
|
||||||
writeValue(root);
|
writeValue(root);
|
||||||
if (!omitEndingLineFeed_)
|
if (!omitEndingLineFeed_)
|
||||||
document_ += "\n";
|
document_ += "\n";
|
||||||
@ -403,9 +403,9 @@ StyledWriter::StyledWriter()
|
|||||||
: rightMargin_(74), indentSize_(3), addChildValues_() {}
|
: rightMargin_(74), indentSize_(3), addChildValues_() {}
|
||||||
|
|
||||||
JSONCPP_STRING StyledWriter::write(const Value& root) {
|
JSONCPP_STRING StyledWriter::write(const Value& root) {
|
||||||
document_ = "";
|
document_.clear();
|
||||||
addChildValues_ = false;
|
addChildValues_ = false;
|
||||||
indentString_ = "";
|
indentString_.clear();
|
||||||
writeCommentBeforeValue(root);
|
writeCommentBeforeValue(root);
|
||||||
writeValue(root);
|
writeValue(root);
|
||||||
writeCommentAfterValueOnSameLine(root);
|
writeCommentAfterValueOnSameLine(root);
|
||||||
@ -619,7 +619,7 @@ StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation)
|
|||||||
void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
|
void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
|
||||||
document_ = &out;
|
document_ = &out;
|
||||||
addChildValues_ = false;
|
addChildValues_ = false;
|
||||||
indentString_ = "";
|
indentString_.clear();
|
||||||
indented_ = true;
|
indented_ = true;
|
||||||
writeCommentBeforeValue(root);
|
writeCommentBeforeValue(root);
|
||||||
if (!indented_) writeIndent();
|
if (!indented_) writeIndent();
|
||||||
@ -901,7 +901,7 @@ int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout)
|
|||||||
sout_ = sout;
|
sout_ = sout;
|
||||||
addChildValues_ = false;
|
addChildValues_ = false;
|
||||||
indented_ = true;
|
indented_ = true;
|
||||||
indentString_ = "";
|
indentString_.clear();
|
||||||
writeCommentBeforeValue(root);
|
writeCommentBeforeValue(root);
|
||||||
if (!indented_) writeIndent();
|
if (!indented_) writeIndent();
|
||||||
indented_ = true;
|
indented_ = true;
|
||||||
@ -1155,10 +1155,10 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
|
|||||||
}
|
}
|
||||||
JSONCPP_STRING nullSymbol = "null";
|
JSONCPP_STRING nullSymbol = "null";
|
||||||
if (dnp) {
|
if (dnp) {
|
||||||
nullSymbol = "";
|
nullSymbol.clear();
|
||||||
}
|
}
|
||||||
if (pre > 17) pre = 17;
|
if (pre > 17) pre = 17;
|
||||||
JSONCPP_STRING endingLineFeedSymbol = "";
|
JSONCPP_STRING endingLineFeedSymbol;
|
||||||
return new BuiltStyledStreamWriter(
|
return new BuiltStyledStreamWriter(
|
||||||
indentation, cs,
|
indentation, cs,
|
||||||
colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);
|
colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user