From af7dd55d34f577e096403596e6631dcaa9c01315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Blanchon?= Date: Wed, 9 Jul 2014 13:16:10 +0200 Subject: [PATCH] Reduced the size of EscapedString::printTo() by 4 bytes --- JsonGenerator/EscapedString.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/JsonGenerator/EscapedString.cpp b/JsonGenerator/EscapedString.cpp index bf7c461c..7671049f 100644 --- a/JsonGenerator/EscapedString.cpp +++ b/JsonGenerator/EscapedString.cpp @@ -11,18 +11,14 @@ static inline char getSpecialChar(char c) { // Optimized for code size on a 8-bit AVR - const char* specials = "\"\"\\\\\bb\ff\nn\rr\tt"; - - while (true) + const char*p = "\"\"\\\\\bb\ff\nn\rr\tt\0"; + + while (p[0] && p[0] != c) { - if (specials[0] == 0) - return 0; - - if (specials[0] == c) - return specials[1]; - - specials += 2; + p += 2; } + + return p[1]; } size_t EscapedString::printTo(Print& p) const