From b5002265cf2783cdc391440b49e9818675e78722 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Tue, 26 Aug 2014 09:53:32 +0200 Subject: [PATCH] Refactoring... --- JsonGenerator/IndentedPrintDecorator.cpp | 17 +++++++---------- JsonGenerator/IndentedPrintDecorator.h | 15 ++++++--------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/JsonGenerator/IndentedPrintDecorator.cpp b/JsonGenerator/IndentedPrintDecorator.cpp index d8680121..7d30e0ca 100644 --- a/JsonGenerator/IndentedPrintDecorator.cpp +++ b/JsonGenerator/IndentedPrintDecorator.cpp @@ -2,12 +2,14 @@ void IndentedPrintDecorator::indent() { - currentTabCount++; + if (level<127) + level++; } void IndentedPrintDecorator::unindent() { - currentTabCount--; + if (level>0) + level--; } size_t IndentedPrintDecorator::write(uint8_t c) @@ -15,7 +17,7 @@ size_t IndentedPrintDecorator::write(uint8_t c) size_t n = 0; if (isNewLine) - n += writeCurrentTabs(); + n += writeTabs(); n += sink.write(c); @@ -24,16 +26,11 @@ size_t IndentedPrintDecorator::write(uint8_t c) return n; } -size_t IndentedPrintDecorator::writeCurrentTabs() -{ - return writeTabs(currentTabCount); -} - -size_t IndentedPrintDecorator::writeTabs(int count) +size_t IndentedPrintDecorator::writeTabs() { size_t n = 0; - for (int i = 0; i