We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Dear JSONCPP developers,
I was looking at the following if statement starting on
jsoncpp/src/lib_json/json_writer.cpp
Line 734 in 69098a1
It took me some time to realize that the rather complex code in the then branch:
Lines 738 to 757 in 69098a1
for (unsigned index = 0; index < size ; ++index) { const Value& childValue = value[index]; writeCommentBeforeValue(childValue); if (hasChildValue) writeWithIndent(childValues_[index]); else { if (!indented_) writeIndent(); indented_ = true; writeValue(childValue); indented_ = false; } if (index < size -1) { *document_ << ","; } writeCommentAfterValueOnSameLine(childValue); }
I assume performance (saving a comparison) is the reason for the extra complexity.
Yet, when looking at the else branch
Lines 764 to 768 in 69098a1
optimized
unsigned index = 0; for (;;) { *document_ << childValues_[index]; if (++index == size) break; *document_ << ", "; }
So I wonder
Thanks in advance for your answers (and possibly code improvements)!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Dear JSONCPP developers,
I was looking at the following if statement starting on
jsoncpp/src/lib_json/json_writer.cpp
Line 734 in 69098a1
It took me some time to realize that the rather complex code in the then branch:
jsoncpp/src/lib_json/json_writer.cpp
Lines 738 to 757 in 69098a1
is equal to joining the elements in the range [0,size) where size != 0 with a separator,
and a functional equivalent, yet simpler, implementation is
I assume performance (saving a comparison) is the reason for the extra complexity.
Yet, when looking at the else branch
jsoncpp/src/lib_json/json_writer.cpp
Lines 764 to 768 in 69098a1
that is not
optimized
, like the then branch, toSo I wonder
Thanks in advance for your answers (and possibly code improvements)!
The text was updated successfully, but these errors were encountered: