diff --git a/src/json.hpp b/src/json.hpp index a4a3fef5..8704134a 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -8733,10 +8733,7 @@ basic_json_parser_66: if (m_start != reinterpret_cast(m_line_buffer.data())) { // copy unprocessed characters to line buffer - m_line_buffer.clear(); - m_line_buffer.append( - reinterpret_cast(m_start), - static_cast(m_limit - m_start)); + m_line_buffer.assign(m_start, m_limit); m_cursor = m_limit; } @@ -8842,18 +8839,16 @@ basic_json_parser_66: // iterate the result between the quotes for (const lexer_char_t* i = m_start + 1; i < m_cursor - 1; ++i) { - // number of non-escaped characters - const size_t n = static_cast(std::find(i, m_cursor - 1, '\\') - i); - - if (n != 0) + // find next escape character + auto e = std::find(i, m_cursor - 1, '\\'); + if (e != i) { - result.append(reinterpret_cast(i), n); - i += n - 1; // -1 because will ++i + result.append(i, e); + i = e - 1; // -1 because of ++i } else { // processing escaped character - // read next character ++i; diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index cb70535a..389adbc6 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -7882,10 +7882,7 @@ class basic_json if (m_start != reinterpret_cast(m_line_buffer.data())) { // copy unprocessed characters to line buffer - m_line_buffer.clear(); - m_line_buffer.append( - reinterpret_cast(m_start), - static_cast(m_limit - m_start)); + m_line_buffer.assign(m_start, m_limit); m_cursor = m_limit; } @@ -7991,18 +7988,16 @@ class basic_json // iterate the result between the quotes for (const lexer_char_t* i = m_start + 1; i < m_cursor - 1; ++i) { - // number of non-escaped characters - const size_t n = static_cast(std::find(i, m_cursor - 1, '\\') - i); - - if (n != 0) + // find next escape character + auto e = std::find(i, m_cursor - 1, '\\'); + if (e != i) { - result.append(reinterpret_cast(i), n); - i += n - 1; // -1 because will ++i + result.append(i, e); + i = e - 1; // -1 because of ++i } else { // processing escaped character - // read next character ++i;