From b98559907900861ea7758fdaeafcd63dedc1638e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Mon, 24 Jun 2019 16:26:08 +0200 Subject: [PATCH] [poincare] Remove unused parameter in SerializationHelper::Prefix --- .../include/poincare/serialization_helper.h | 1 - poincare/src/nth_root_layout.cpp | 2 +- poincare/src/serialization_helper.cpp | 23 +++++++------------ 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/poincare/include/poincare/serialization_helper.h b/poincare/include/poincare/serialization_helper.h index ac38a895f..29d47aa91 100644 --- a/poincare/include/poincare/serialization_helper.h +++ b/poincare/include/poincare/serialization_helper.h @@ -31,7 +31,6 @@ namespace SerializationHelper { Preferences::PrintFloatMode floatDisplayMode, int numberOfDigits, const char * operatorName, - int firstChildIndex = 0, int lastChildIndex = -1); int SerializeChild( diff --git a/poincare/src/nth_root_layout.cpp b/poincare/src/nth_root_layout.cpp index 1e31536af..7eb8b2e04 100644 --- a/poincare/src/nth_root_layout.cpp +++ b/poincare/src/nth_root_layout.cpp @@ -152,7 +152,7 @@ int NthRootLayoutNode::serialize(char * buffer, int bufferSize, Preferences::Pri assert((const_cast(this))->indexLayout()); if ((const_cast(this))->indexLayout()->isEmpty()) { // Case: root(x,empty): Write "'SquareRootSymbol'('radicandLayout')" - return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, SquareRoot::s_functionHelper.name(), true, false); + return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, SquareRoot::s_functionHelper.name(), 0); } // Case: root(x,n) return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, NthRoot::s_functionHelper.name()); diff --git a/poincare/src/serialization_helper.cpp b/poincare/src/serialization_helper.cpp index 2f9b1f773..860c3d0fa 100644 --- a/poincare/src/serialization_helper.cpp +++ b/poincare/src/serialization_helper.cpp @@ -117,7 +117,6 @@ int SerializationHelper::Prefix( Preferences::PrintFloatMode floatDisplayMode, int numberOfDigits, const char * operatorName, - int firstChildIndex, int lastChildIndex) { { @@ -142,22 +141,16 @@ int SerializationHelper::Prefix( int childrenCount = node->numberOfChildren(); if (childrenCount > 0) { - assert(childrenCount > firstChildIndex); int lastIndex = lastChildIndex < 0 ? childrenCount - 1 : lastChildIndex; - assert(firstChildIndex <= lastIndex); - // Write the first child - numberOfChar += node->childAtIndex(firstChildIndex)->serialize(buffer+numberOfChar, bufferSize-numberOfChar, floatDisplayMode, numberOfDigits); - if (numberOfChar >= bufferSize-1) { - assert(buffer[bufferSize - 1] == 0); - return bufferSize-1; - } - - // Write the remaining children, separated with commas - for (int i = firstChildIndex + 1; i <= lastIndex; i++) { - numberOfChar += UTF8Decoder::CodePointToChars(',', buffer+numberOfChar, bufferSize - numberOfChar); - if (numberOfChar >= bufferSize-1) { - return bufferSize-1; + // Write the children, separated with commas + for (int i = 0; i <= lastIndex; i++) { + if (i != 0) { + // Write the comma + numberOfChar += UTF8Decoder::CodePointToChars(',', buffer+numberOfChar, bufferSize - numberOfChar); + if (numberOfChar >= bufferSize-1) { + return bufferSize-1; + } } numberOfChar += node->childAtIndex(i)->serialize(buffer+numberOfChar, bufferSize-numberOfChar, floatDisplayMode, numberOfDigits); if (numberOfChar >= bufferSize-1) {