Skip to content

Commit 40cdbcc

Browse files
committed
chore: improve buffer resize size
1 parent adafd01 commit 40cdbcc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/parser.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,11 @@ function parseType (parser, type) {
314314
function decreaseBufferPool () {
315315
if (bufferPool.length > 50 * 1024) {
316316
if (counter === 1 || notDecreased > counter * 2) {
317-
const sliceLength = Math.floor(bufferPool.length / 10)
318-
if (bufferOffset <= sliceLength) {
319-
bufferOffset = 0
320-
} else {
321-
bufferOffset -= sliceLength
322-
}
317+
const minSliceLen = Math.floor(bufferPool.length / 10)
318+
const sliceLength = minSliceLen < bufferOffset
319+
? bufferOffset
320+
: minSliceLen
321+
bufferOffset = 0
323322
bufferPool = bufferPool.slice(sliceLength, bufferPool.length)
324323
} else {
325324
notDecreased++

0 commit comments

Comments
 (0)