Skip to content

Commit 7cc6373

Browse files
committed
toon use span
1 parent 9309c90 commit 7cc6373

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

include/jsoncons_ext/toon/toon_reader.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ jsoncons::expected<void,std::error_code> parse_primitive(jsoncons::span<char> to
471471

472472
struct header_info
473473
{
474-
jsoncons::optional<std::string> key;
474+
jsoncons::optional<jsoncons::string_view> key;
475475
std::size_t length{0};
476476
char delimiter{','};
477477
std::vector<jsoncons::string_view> fields;
@@ -919,7 +919,7 @@ header_result parse_header(jsoncons::span<char> line)
919919
{
920920
return header_result{};
921921
}
922-
auto key = jsoncons::optional<std::string>{};
922+
auto key = jsoncons::optional<jsoncons::string_view>{};
923923
if (bracket_start > 0)
924924
{
925925
auto key_part = strip(jsoncons::span<char>{line.data(), bracket_start});
@@ -930,7 +930,7 @@ header_result parse_header(jsoncons::span<char> line)
930930
{
931931
return header_result{jsoncons::unexpect, rkey.error()};
932932
}
933-
key = std::string{*rkey};
933+
key = *rkey;
934934
}
935935
}
936936
auto bracket_end = find_unquoted_char(line, ']', bracket_start);
@@ -994,7 +994,7 @@ header_result parse_header(jsoncons::span<char> line)
994994
{
995995
fields.clear();
996996
}
997-
return header_result{jsoncons::in_place, header_info{jsoncons::optional<std::string>{std::move(key)}, length, delimiter, std::move(fields)}};
997+
return header_result{jsoncons::in_place, header_info{jsoncons::optional<jsoncons::string_view>{key}, length, delimiter, std::move(fields)}};
998998
}
999999

10001000
inline
@@ -1212,7 +1212,7 @@ line_result decode_object(const std::vector<parsed_line>& lines,
12121212
if (*header_result)
12131213
{
12141214
const header_info& header(*(*header_result));
1215-
const jsoncons::optional<std::string>& key(header.key);
1215+
auto key = header.key;
12161216
if (key)
12171217
{
12181218
// Array field
@@ -1338,7 +1338,7 @@ line_result decode_list_array(const std::vector<parsed_line>& lines,
13381338
if (*item_header_result)
13391339
{
13401340
const header_info& item_header(*(*item_header_result));
1341-
const jsoncons::optional<std::string>& key(item_header.key);
1341+
auto key = item_header.key;
13421342
std::size_t length{item_header.length};
13431343
char item_delim{item_header.delimiter};
13441344

@@ -1404,7 +1404,7 @@ line_result decode_list_array(const std::vector<parsed_line>& lines,
14041404
if (*field_header_result)
14051405
{
14061406
const header_info& field_header (*(*field_header_result));
1407-
const jsoncons::optional<std::string>& field_key(field_header.key);
1407+
auto field_key = field_header.key;
14081408

14091409
visitor.key(*field_key);
14101410
auto r1 = decode_array_from_header(lines, false, i, field_line.depth, field_header, options, visitor);
@@ -1512,7 +1512,7 @@ line_result decode_list_array(const std::vector<parsed_line>& lines,
15121512
if (*field_header_result)
15131513
{
15141514
const header_info& field_header (*(*field_header_result));
1515-
const auto& field_key{field_header.key};
1515+
auto field_key = field_header.key;
15161516
visitor.key(*field_key);
15171517
auto r1 = decode_array_from_header(lines, false, i, field_line.depth, field_header, options, visitor);
15181518
if (!r1)
@@ -1673,7 +1673,7 @@ line_result decode_array_from_header(const std::vector<parsed_line>& lines,
16731673
const toon_decode_options& options,
16741674
json_visitor& visitor)
16751675
{
1676-
const jsoncons::optional<std::string>& key(header_info.key);
1676+
auto key = header_info.key;
16771677
std::size_t length{header_info.length};
16781678
char delimiter{header_info.delimiter};
16791679
const std::vector<jsoncons::string_view>& fields{header_info.fields};

0 commit comments

Comments
 (0)