Created
September 7, 2020 15:51
-
-
Save vinniefalco/c05e72b35914306876f9c1c2292ef690 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static | |
void | |
serialize_impl( | |
string& s, | |
serializer& sr) | |
{ | |
// serialize to a small buffer | |
// to avoid most reallocations | |
char buf[16384]; | |
string_view sv; | |
sv = sr.read(buf); | |
if(sr.done()) | |
{ | |
s.append(sv); | |
return; | |
} | |
s.reserve(sv.size() * 2); | |
s.append(sv); | |
do | |
{ | |
sv = sr.read( | |
s.data() + s.size(), | |
s.capacity() - s.size()); | |
s.grow(sv.size()); | |
} | |
while(! sr.done()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment