use range-based for in escape_JSON() function
This commit is contained in:
parent
11c671354b
commit
d853310bee
@ -88,9 +88,9 @@ inline std::string escape_JSON(const std::string &input)
|
|||||||
// escape and skip reallocations if possible
|
// escape and skip reallocations if possible
|
||||||
std::string output;
|
std::string output;
|
||||||
output.reserve(input.size() + 4); // +4 assumes two backslashes on avg
|
output.reserve(input.size() + 4); // +4 assumes two backslashes on avg
|
||||||
for (auto iter = input.begin(); iter != input.end(); ++iter)
|
for (const char letter : input)
|
||||||
{
|
{
|
||||||
switch (iter[0])
|
switch (letter)
|
||||||
{
|
{
|
||||||
case '\\':
|
case '\\':
|
||||||
output += "\\\\";
|
output += "\\\\";
|
||||||
@ -117,7 +117,7 @@ inline std::string escape_JSON(const std::string &input)
|
|||||||
output += "\\t";
|
output += "\\t";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
output += *iter;
|
output.append(1, letter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user