Refactoring....

This commit is contained in:
Benoit Blanchon
2014-08-25 12:28:58 +02:00
parent 752378a8cb
commit 9e88514700

View File

@ -75,30 +75,20 @@ size_t PrettyPrintDecorator::writeComma()
size_t PrettyPrintDecorator::writeOpening(uint8_t c) size_t PrettyPrintDecorator::writeOpening(uint8_t c)
{ {
size_t n; bool inEmptyBlock = previousChar == '{' || previousChar == '[';
if (previousChar == '{' || previousChar == '[') size_t n = inEmptyBlock ? writeln() + sink.write(c) : sink.write(c);
{
n = writeln() + sink.write(c);
}
else
{
n = sink.write(c);
}
indent++; indent++;
return n; return n;
} }
size_t PrettyPrintDecorator::writeClosing(uint8_t c) size_t PrettyPrintDecorator::writeClosing(uint8_t c)
{ {
bool inEmptyBlock = previousChar == '{' || previousChar == '[';
indent--; indent--;
if (previousChar == '{' || previousChar == '[')
{ return inEmptyBlock ? sink.write(c) : writeln() + sink.write(c);
return sink.write(c);
}
else
{
return writeln() + sink.write(c);
}
} }