@@ -365,7 +365,8 @@ BENCHMARK(twitter_image_sizes);
365
365
static void error_code_twitter_count (State& state) noexcept {
366
366
// Prints the number of results in twitter.json
367
367
dom::parser parser;
368
- dom::element doc = parser.load (TWITTER_JSON);
368
+ auto [doc, error1] = parser.load (TWITTER_JSON);
369
+ if (error1) { return ; }
369
370
for (UNUSED auto _ : state) {
370
371
auto [value, error] = doc[" search_metadata" ][" count" ].get <uint64_t >();
371
372
if (error) { return ; }
@@ -377,7 +378,8 @@ BENCHMARK(error_code_twitter_count);
377
378
static void error_code_twitter_default_profile (State& state) noexcept {
378
379
// Count unique users with a default profile.
379
380
dom::parser parser;
380
- dom::element doc = parser.load (TWITTER_JSON);
381
+ auto [doc, error1] = parser.load (TWITTER_JSON);
382
+ if (error1) { std::cerr << error1 << std::endl; return ; }
381
383
for (UNUSED auto _ : state) {
382
384
set<string_view> default_users;
383
385
@@ -404,7 +406,8 @@ SIMDJSON_PUSH_DISABLE_WARNINGS
404
406
SIMDJSON_DISABLE_DEPRECATED_WARNING
405
407
static void iterator_twitter_default_profile (State& state) {
406
408
// Count unique users with a default profile.
407
- padded_string json = padded_string::load (TWITTER_JSON);
409
+ auto [json, error1] = padded_string::load (TWITTER_JSON);
410
+ if (error1) { std::cerr << error1 << std::endl; return ; }
408
411
ParsedJson pj = build_parsed_json (json);
409
412
for (UNUSED auto _ : state) {
410
413
set<string_view> default_users;
@@ -444,7 +447,8 @@ BENCHMARK(iterator_twitter_default_profile);
444
447
static void error_code_twitter_image_sizes (State& state) noexcept {
445
448
// Count unique image sizes
446
449
dom::parser parser;
447
- dom::element doc = parser.load (TWITTER_JSON);
450
+ auto [doc, error1] = parser.load (TWITTER_JSON);
451
+ if (error1) { std::cerr << error1 << std::endl; return ; }
448
452
for (UNUSED auto _ : state) {
449
453
set<tuple<uint64_t , uint64_t >> image_sizes;
450
454
auto [statuses, error] = doc[" statuses" ].get <dom::array>();
@@ -473,7 +477,8 @@ SIMDJSON_PUSH_DISABLE_WARNINGS
473
477
SIMDJSON_DISABLE_DEPRECATED_WARNING
474
478
static void iterator_twitter_image_sizes (State& state) {
475
479
// Count unique image sizes
476
- padded_string json = padded_string::load (TWITTER_JSON);
480
+ auto [json, error1] = padded_string::load (TWITTER_JSON);
481
+ if (error1) { std::cerr << error1 << std::endl; return ; }
477
482
ParsedJson pj = build_parsed_json (json);
478
483
for (UNUSED auto _ : state) {
479
484
set<tuple<uint64_t , uint64_t >> image_sizes;
@@ -531,7 +536,8 @@ BENCHMARK(iterator_twitter_image_sizes);
531
536
532
537
static void print_json (State& state) noexcept {
533
538
// Prints the number of results in twitter.json
534
- padded_string json = get_corpus (TWITTER_JSON);
539
+ auto [json, error1] = padded_string::load (TWITTER_JSON);
540
+ if (error1) { std::cerr << error1 << std::endl; return ; }
535
541
dom::parser parser;
536
542
if (int error = json_parse (json, parser); error != SUCCESS) { cerr << error_message (error) << endl; return ; }
537
543
for (UNUSED auto _ : state) {
0 commit comments