Skip to content

Commit dc0619e

Browse files
committed
Better comments, expanded two-chars insertion
1 parent 18ce6f7 commit dc0619e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

include/nlohmann/detail/string_escape.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace detail
1515
{
1616

1717
/*!
18-
* @brief Out Of Place string escaping as described in RFC 6901 (Sect. 4)
18+
* @brief Returns a copy of a string escaped as described in RFC 6901 (Sect. 4)
1919
* @param[in] s string to escape
2020
* @return escaped string
2121
*
@@ -45,11 +45,13 @@ inline StringType escape(StringType const& s)
4545
{
4646
if (ch == CharT('~'))
4747
{
48-
res.append(StringType{"~0"});
48+
res.push_back(CharT('~'));
49+
res.push_back(CharT{'0'});
4950
}
5051
else if (ch == CharT('/'))
5152
{
52-
res.append(StringType{"~1"});
53+
res.push_back(CharT{'~'});
54+
res.push_back(CharT{'1'});
5355
}
5456
else
5557
{
@@ -61,7 +63,7 @@ inline StringType escape(StringType const& s)
6163
}
6264

6365
/*!
64-
* @brief In Place string unescaping as described in RFC 6901 (Sect. 4)
66+
* @brief Unescapes a string as described in RFC 6901 (Sect. 4), in-place
6567
* @param[in] s string to unescape
6668
*
6769
*/

0 commit comments

Comments
 (0)