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

This commit is contained in:
Benoît Blanchon
2014-07-09 13:16:10 +02:00
parent 525649c416
commit af7dd55d34

View File

@ -11,18 +11,14 @@ static inline char getSpecialChar(char c)
{ {
// Optimized for code size on a 8-bit AVR // Optimized for code size on a 8-bit AVR
const char* specials = "\"\"\\\\\bb\ff\nn\rr\tt"; const char*p = "\"\"\\\\\bb\ff\nn\rr\tt\0";
while (true) while (p[0] && p[0] != c)
{ {
if (specials[0] == 0) p += 2;
return 0;
if (specials[0] == c)
return specials[1];
specials += 2;
} }
return p[1];
} }
size_t EscapedString::printTo(Print& p) const size_t EscapedString::printTo(Print& p) const