@@ -381,16 +381,9 @@ func ReadMsgSectionSingleDocument(src []byte) (doc bsoncore.Document, rem []byte
381
381
// ReadMsgSectionDocumentSequence reads an identifier and document sequence from src and returns the document sequence
382
382
// data parsed into a slice of BSON documents.
383
383
func ReadMsgSectionDocumentSequence (src []byte ) (identifier string , docs []bsoncore.Document , rem []byte , ok bool ) {
384
- length , rem , ok := readi32 (src )
385
- if ! ok || int (length ) > len (src ) || length - 4 < 0 {
386
- return "" , nil , rem , false
387
- }
388
-
389
- rem , ret := rem [:length - 4 ], rem [length - 4 :] // reslice so we can just iterate a loop later
390
-
391
- identifier , rem , ok = readcstring (rem )
384
+ identifier , rem , ret , ok := ReadMsgSectionRawDocumentSequence (src )
392
385
if ! ok {
393
- return "" , nil , rem , false
386
+ return "" , nil , src , false
394
387
}
395
388
396
389
docs = make ([]bsoncore.Document , 0 )
@@ -403,7 +396,7 @@ func ReadMsgSectionDocumentSequence(src []byte) (identifier string, docs []bsonc
403
396
docs = append (docs , doc )
404
397
}
405
398
if len (rem ) > 0 {
406
- return "" , nil , append ( rem , ret ... ) , false
399
+ return "" , nil , src , false
407
400
}
408
401
409
402
return identifier , docs , ret , true
@@ -414,7 +407,7 @@ func ReadMsgSectionDocumentSequence(src []byte) (identifier string, docs []bsonc
414
407
func ReadMsgSectionRawDocumentSequence (src []byte ) (identifier string , data []byte , rem []byte , ok bool ) {
415
408
length , rem , ok := readi32 (src )
416
409
if ! ok || int (length ) > len (src ) || length - 4 < 0 {
417
- return "" , nil , rem , false
410
+ return "" , nil , src , false
418
411
}
419
412
420
413
// After these assignments, rem will be the data containing the identifier string + the document sequence bytes and
@@ -423,7 +416,7 @@ func ReadMsgSectionRawDocumentSequence(src []byte) (identifier string, data []by
423
416
424
417
identifier , rem , ok = readcstring (rem )
425
418
if ! ok {
426
- return "" , nil , rem , false
419
+ return "" , nil , src , false
427
420
}
428
421
429
422
return identifier , rem , rest , true
@@ -546,14 +539,6 @@ func ReadCompressedCompressorID(src []byte) (id CompressorID, rem []byte, ok boo
546
539
return CompressorID (src [0 ]), src [1 :], true
547
540
}
548
541
549
- // ReadCompressedCompressedMessage reads the compressed wiremessage to dst.
550
- func ReadCompressedCompressedMessage (src []byte , length int32 ) (msg []byte , rem []byte , ok bool ) {
551
- if len (src ) < int (length ) || length < 0 {
552
- return nil , src , false
553
- }
554
- return src [:length ], src [length :], true
555
- }
556
-
557
542
// ReadKillCursorsZero reads the zero field from src.
558
543
func ReadKillCursorsZero (src []byte ) (zero int32 , rem []byte , ok bool ) {
559
544
return readi32 (src )
0 commit comments