summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2012-03-24 12:58:15 -0700
committerJosh Haberman <jhaberman@gmail.com>2012-03-24 12:58:15 -0700
commit26ed1e996171c8ffa2ced42ac69b1b82c1956e1f (patch)
tree6c844e2043ece3fdf0ea7dbc8e2f1950b76894c0
parentbf0308ebc5508d7c045859deda987e488b0801d6 (diff)
Got our performance back by tweaking AssignToString.
plain.parsetoproto2_googlemessage1.upb_jit: 254 -> 324 (27.56) omitfp.parsetoproto2_googlemessage1.upb_jit: 220 -> 332 (50.91)
-rw-r--r--bindings/cpp/upb/bytestream.hpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/bindings/cpp/upb/bytestream.hpp b/bindings/cpp/upb/bytestream.hpp
index 81134b9..8b48690 100644
--- a/bindings/cpp/upb/bytestream.hpp
+++ b/bindings/cpp/upb/bytestream.hpp
@@ -207,11 +207,12 @@ class ByteRegion : public upb_byteregion {
template <typename T> void AssignToString(T* str) {
uint64_t ofs = start_ofs();
- str->clear();
- str->reserve(Length());
+ size_t len;
+ const char *ptr = GetPtr(ofs, &len);
+ str->assign(ptr, len);
+ ofs += len;
while (ofs < end_ofs()) {
- size_t len;
- const char *ptr = GetPtr(ofs, &len);
+ ptr = GetPtr(ofs, &len);
str->append(ptr, len);
ofs += len;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback