Skip to content

Commit 558a3d9

Browse files
committed
Replacing control character search in json::details::_String class from std::string::find_first_of to std::any_of.
1 parent d93bc39 commit 558a3d9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Release/src/json/json.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,13 @@ bool web::json::number::is_int64() const
340340

341341
bool web::json::details::_String::has_escape_chars(const _String &str)
342342
{
343-
static const std::array<::utility::string_t::value_type, 34> escapes =
344-
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 0x00 - 0x1F */ '\"', '\\' };
345-
346-
// Provide the range otherwise find_first_of will think the first null terminator character is the end.
347-
return str.m_string.find_first_of(escapes.data(), 0, escapes.size()) != utility::string_t::npos;
343+
return std::any_of(std::begin(str.m_string), std::end(str.m_string), [](utility::string_t::value_type const x)
344+
{
345+
if (x >= 0 && x <= 31) { return true; }
346+
if (x == '"') { return true; }
347+
if (x == '\\') { return true; }
348+
return false;
349+
});
348350
}
349351

350352
web::json::details::_Object::_Object(const _Object& other) :

0 commit comments

Comments
 (0)