From cca4818eb7769d6e776bdc30516a5f871f1d6393 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sat, 31 Mar 2012 12:17:32 -0700 Subject: Sync from internal Google development. --- bindings/cpp/upb/bytestream.hpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'bindings/cpp/upb/bytestream.hpp') diff --git a/bindings/cpp/upb/bytestream.hpp b/bindings/cpp/upb/bytestream.hpp index 8b48690..37d8157 100644 --- a/bindings/cpp/upb/bytestream.hpp +++ b/bindings/cpp/upb/bytestream.hpp @@ -209,6 +209,10 @@ class ByteRegion : public upb_byteregion { uint64_t ofs = start_ofs(); size_t len; const char *ptr = GetPtr(ofs, &len); + // Emperically calling reserve() here is counterproductive and slows down + // benchmarks. If the parsing is happening in a tight loop that is reusing + // the string object, there is probably enough data reserved already and + // the reserve() call is extra overhead. str->assign(ptr, len); ofs += len; while (ofs < end_ofs()) { -- cgit v1.2.3