1
0
Fork 0

optimize out unnecessary allocation

This commit is contained in:
Kevin Matz 2023-05-13 11:31:01 -04:00
parent 4cc4d16fba
commit 28c7bba442
1 changed files with 2 additions and 4 deletions

View File

@ -73,8 +73,7 @@ void blob::iStream(std::shared_ptr<bufferstream> stream)
auto length = stream->readType<int32_t>();
value.resize(length);
stream->read(value.data(), length);
auto pad = length % 4;
for (int i = 0; i < pad; i++)
for (uint padding = length % 4; padding > 0; padding--)
stream->readType<uint8_t>();
}
@ -82,8 +81,7 @@ void blob::iStream(std::shared_ptr<bufferstream> stream)
void blob::oStream(std::shared_ptr<bufferstream> stream) const
{
stream->writeType<int32_t>(value.size());
auto pad = value.size() % 4;
for (uint i = 0; i < pad; i++)
for (uint padding = value.size() % 4; padding > 0; padding--)
stream->readType<uint8_t>();
}