forked from bblanchon/ArduinoJson
Reduced the size of EscapedString::printTo() by 26 bytes
This commit is contained in:
@ -9,31 +9,19 @@ using namespace ArduinoJson::Internals;
|
|||||||
|
|
||||||
static inline char getSpecialChar(char c)
|
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 '"':
|
if (specials[0] == 0)
|
||||||
return '"';
|
return 0;
|
||||||
|
|
||||||
case '\\':
|
if (specials[0] == c)
|
||||||
return '\\';
|
return specials[1];
|
||||||
|
|
||||||
case '\b':
|
specials += 2;
|
||||||
return 'b';
|
|
||||||
|
|
||||||
case '\f':
|
|
||||||
return 'f';
|
|
||||||
|
|
||||||
case '\n':
|
|
||||||
return 'n';
|
|
||||||
|
|
||||||
case '\r':
|
|
||||||
return 'r';
|
|
||||||
|
|
||||||
case '\t':
|
|
||||||
return 't';
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user