summaryrefslogtreecommitdiff
path: root/bindings/cpp/upb/bytestream.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/cpp/upb/bytestream.hpp')
-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