diff --git a/benchmarks/compare.py b/benchmarks/compare.py index 48f9704e11..9bdf787138 100755 --- a/benchmarks/compare.py +++ b/benchmarks/compare.py @@ -45,7 +45,9 @@ def Benchmark(outbase, bench_cpu=True, runs=12, fasttable=False): # Translate into the format expected by benchstat. with open(outbase + ".txt", "w") as f: for run in bench_json["benchmarks"]: - name = re.sub(r'^BM_', 'Benchmark', run["name"]) + name = run["name"] + name = name.replace(" ", "") + name = re.sub(r'^BM_', 'Benchmark', name) if name.endswith("_mean") or name.endswith("_median") or name.endswith("_stddev"): continue values = (name, run["iterations"], run["cpu_time"]) diff --git a/upb/decode.c b/upb/decode.c index 26a8d42315..d2ba8c25ea 100644 --- a/upb/decode.c +++ b/upb/decode.c @@ -221,11 +221,18 @@ static const char *decode_varint64(upb_decstate *d, const char *ptr, UPB_FORCEINLINE static const char *decode_varint32(upb_decstate *d, const char *ptr, uint32_t *val) { - uint64_t u64; - ptr = decode_varint64(d, ptr, &u64); - if (u64 > UINT32_MAX) decode_err(d); - *val = (uint32_t)u64; - return ptr; + uint64_t byte = (uint8_t)*ptr; + if (UPB_LIKELY((byte & 0x80) == 0)) { + *val = byte; + return ptr + 1; + } else { + const char *start = ptr; + decode_vret res = decode_longvarint64(ptr, byte); + ptr = res.ptr; + *val = res.val; + if (!ptr || *val > UINT32_MAX || ptr - start > 5) decode_err(d); + return ptr; + } } static void decode_munge(int type, wireval *val) {