Some small changes as a result of using a static analyzer (#643)

* Removed an expression which is always true
* The second expression (ch is space) is removed because the first one contains space 0x20
* nextEmptyLine is always false so it is removed from the expression
This commit is contained in:
Alexander Anokhin
2018-11-23 20:12:55 +03:00
committed by Jesse Beder
parent 2443da5224
commit b659858b19
3 changed files with 4 additions and 6 deletions

View File

@@ -285,10 +285,8 @@ void Emitter::PrepareTopNode(EmitterNodeType::value child) {
if (child == EmitterNodeType::NoType) if (child == EmitterNodeType::NoType)
return; return;
if (m_pState->CurGroupChildCount() > 0 && m_stream.col() > 0) { if (m_pState->CurGroupChildCount() > 0 && m_stream.col() > 0)
if (child != EmitterNodeType::NoType)
EmitBeginDoc(); EmitBeginDoc();
}
switch (child) { switch (child) {
case EmitterNodeType::NoType: case EmitterNodeType::NoType:

View File

@@ -382,7 +382,7 @@ bool WriteChar(ostream_wrapper& out, char ch) {
out << "\"\\b\""; out << "\"\\b\"";
} else if (ch == '\\') { } else if (ch == '\\') {
out << "\"\\\\\""; out << "\"\\\\\"";
} else if ((0x20 <= ch && ch <= 0x7e) || ch == ' ') { } else if (0x20 <= ch && ch <= 0x7e) {
out << "\"" << ch << "\""; out << "\"" << ch << "\"";
} else { } else {
out << "\""; out << "\"";

View File

@@ -183,7 +183,7 @@ std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) {
case FOLD_FLOW: case FOLD_FLOW:
if (nextEmptyLine) { if (nextEmptyLine) {
scalar += "\n"; scalar += "\n";
} else if (!emptyLine && !nextEmptyLine && !escapedNewline) { } else if (!emptyLine && !escapedNewline) {
scalar += " "; scalar += " ";
} }
break; break;