Skip to content

Commit

Permalink
Bound stdout shifting to prevent excessive allocations (#941)
Browse files Browse the repository at this point in the history
I noticed this when using an incremental rebuild. In my project, the `stdout` can grow to 100mb+ during the initial build. During rebuild, the `stdout` is mostly empty. But the old code used an unbounded `slice`, which allocated almost the full 100mb.
  • Loading branch information
jridgewell authored Mar 10, 2021
1 parent d198603 commit d8f281e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ export function createChannel(streamIn: StreamIn): StreamOut {
offset += length;
}
if (offset > 0) {
stdout.set(stdout.slice(offset));
stdout.copyWithin(0, offset, stdoutUsed);
stdoutUsed -= offset;
}
};
Expand Down

0 comments on commit d8f281e

Please sign in to comment.