Skip to content

Commit 07364bc

Browse files
committed
chore: remove obsolete variable
1 parent 40cdbcc commit 07364bc

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/parser.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ function parseBulkString (parser) {
153153
const offsetEnd = parser.offset + length
154154
if (offsetEnd + 2 > parser.buffer.length) {
155155
parser.bigStrSize = offsetEnd + 2
156-
parser.bigOffset = parser.offset
157156
parser.totalChunkSize = parser.buffer.length
158157
parser.bufferCache.push(parser.buffer)
159158
return
@@ -257,7 +256,7 @@ function parseArrayElements (parser, responses, i) {
257256
}
258257
const response = parseType(parser, parser.buffer[parser.offset++])
259258
if (response === undefined) {
260-
if (!parser.arrayCache.length) {
259+
if (!parser.arrayCache.length && !parser.bufferCache.length) {
261260
parser.offset = offset
262261
}
263262
pushArrayCache(parser, responses, i)
@@ -366,17 +365,18 @@ function resizeBuffer (length) {
366365
*/
367366
function concatBulkString (parser) {
368367
const list = parser.bufferCache
368+
const oldOffset = parser.offset
369369
var chunks = list.length
370370
var offset = parser.bigStrSize - parser.totalChunkSize
371371
parser.offset = offset
372372
if (offset <= 2) {
373373
if (chunks === 2) {
374-
return list[0].toString('utf8', parser.bigOffset, list[0].length + offset - 2)
374+
return list[0].toString('utf8', oldOffset, list[0].length + offset - 2)
375375
}
376376
chunks--
377377
offset = list[list.length - 2].length + offset
378378
}
379-
var res = decoder.write(list[0].slice(parser.bigOffset))
379+
var res = decoder.write(list[0].slice(oldOffset))
380380
for (var i = 1; i < chunks - 1; i++) {
381381
res += decoder.write(list[i])
382382
}
@@ -394,21 +394,22 @@ function concatBulkString (parser) {
394394
*/
395395
function concatBulkBuffer (parser) {
396396
const list = parser.bufferCache
397-
const length = parser.bigStrSize - parser.bigOffset - 2
397+
const oldOffset = parser.offset
398+
const length = parser.bigStrSize - oldOffset - 2
398399
var chunks = list.length
399400
var offset = parser.bigStrSize - parser.totalChunkSize
400401
parser.offset = offset
401402
if (offset <= 2) {
402403
if (chunks === 2) {
403-
return list[0].slice(parser.bigOffset, list[0].length + offset - 2)
404+
return list[0].slice(oldOffset, list[0].length + offset - 2)
404405
}
405406
chunks--
406407
offset = list[list.length - 2].length + offset
407408
}
408409
resizeBuffer(length)
409410
const start = bufferOffset
410-
list[0].copy(bufferPool, start, parser.bigOffset, list[0].length)
411-
bufferOffset += list[0].length - parser.bigOffset
411+
list[0].copy(bufferPool, start, oldOffset, list[0].length)
412+
bufferOffset += list[0].length - oldOffset
412413
for (var i = 1; i < chunks - 1; i++) {
413414
list[i].copy(bufferPool, bufferOffset)
414415
bufferOffset += list[i].length
@@ -448,7 +449,6 @@ class JavascriptRedisParser {
448449
this.offset = 0
449450
this.buffer = null
450451
this.bigStrSize = 0
451-
this.bigOffset = 0
452452
this.totalChunkSize = 0
453453
this.bufferCache = []
454454
this.arrayCache = []
@@ -530,7 +530,7 @@ class JavascriptRedisParser {
530530
const type = this.buffer[this.offset++]
531531
const response = parseType(this, type)
532532
if (response === undefined) {
533-
if (!this.arrayCache.length) {
533+
if (!this.arrayCache.length && !this.bufferCache.length) {
534534
this.offset = offset
535535
}
536536
return

0 commit comments

Comments
 (0)