Make the overhead computation look less like it has an integer underflow

This commit is contained in:
Drew Fisher authored and Kenton Varda committed 2016-07-03 21:58:04 -07:00
1 parent 533aa8043d
commit f7066436e9
1 file changed
+1 -1
+1 -1
View File
@@ -1815,7 +1815,7 @@ void toBytesPacked(const v8::FunctionCallbackInfo<v8::Value>& args) {
liftKj(args, [&]() -> v8::Handle<v8::Value> {
auto unpackedSize = computeSerializedSizeInWords(builder.message) * sizeof(capnp::word);
// Packed encoding can add 2 bytes of overhead per 2k segment reached.
auto packedOverhead = (((unpackedSize - 1) / 2048) + 1) * 2;
auto packedOverhead = ((unpackedSize + 2047) / 2048) * 2;
auto packedSizeUpperBound = unpackedSize + packedOverhead;
auto oversizedBuf = kj::heapArray<byte>(packedSizeUpperBound);
kj::ArrayOutputStream outputStream(oversizedBuf);