Reduced the size of EscapedString::printTo() by 26 bytes

This commit is contained in:
Benoît Blanchon
2014-07-09 12:57:50 +02:00
parent 1f86016320
commit 525649c416

View File

@ -9,31 +9,19 @@ using namespace ArduinoJson::Internals;
static inline char getSpecialChar(char c)
{
switch (c)
// Optimized for code size on a 8-bit AVR
const char* specials = "\"\"\\\\\bb\ff\nn\rr\tt";
while (true)
{
case '"':
return '"';
if (specials[0] == 0)
return 0;
case '\\':
return '\\';
if (specials[0] == c)
return specials[1];
case '\b':
return 'b';
case '\f':
return 'f';
case '\n':
return 'n';
case '\r':
return 'r';
case '\t':
return 't';
default:
return 0;
specials += 2;
}
}