From 3f688b267705132e4817f96075dc04f305375bb4 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Fri, 21 Aug 2020 15:51:48 +1000 Subject: [PATCH] Optimize example/jsonptr token VBD switch On a mid-range x86_64 laptop, processing the 181 MiB citylots.json file from github.com/zemirco/sf-city-lots-json: $ time gen/bin/example-jsonptr < citylots.json > /dev/null Before this commit: real 0m1.765s After: real 0m1.687s Ratio: 1.05x --- example/jsonptr/jsonptr.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/example/jsonptr/jsonptr.cc b/example/jsonptr/jsonptr.cc index baa03b11..b355a104 100644 --- a/example/jsonptr/jsonptr.cc +++ b/example/jsonptr/jsonptr.cc @@ -1222,15 +1222,11 @@ handle_token(wuffs_base__token t, bool start_of_token_chain) { TRY(handle_unicode_code_point(vbd)); g_query.incremental_match_code_point(vbd); return nullptr; - - case WUFFS_BASE__TOKEN__VBC__LITERAL: - case WUFFS_BASE__TOKEN__VBC__NUMBER: - TRY(write_dst(tok.ptr, tok.len)); - goto after_value; } - // Return an error if we didn't match the (vbc, vbd) pair. - return "main: internal error: unexpected token"; + // We have a literal or a number. + TRY(write_dst(tok.ptr, tok.len)); + goto after_value; } while (0); // Book-keeping after completing a value (whether a container value or a