@@ -479,6 +479,20 @@ type FetchItemDataModSeq struct {
479
479
480
480
func (FetchItemDataModSeq ) fetchItemData () {}
481
481
482
+ // FetchBodySectionBuffer is a buffer for the data returned by
483
+ // FetchItemBodySection.
484
+ type FetchBodySectionBuffer struct {
485
+ Section * imap.FetchItemBodySection
486
+ Bytes []byte
487
+ }
488
+
489
+ // FetchBinarySectionBuffer is a buffer for the data returned by
490
+ // FetchItemBinarySection.
491
+ type FetchBinarySectionBuffer struct {
492
+ Section * imap.FetchItemBinarySection
493
+ Bytes []byte
494
+ }
495
+
482
496
// FetchMessageBuffer is a buffer for the data returned by FetchMessageData.
483
497
//
484
498
// The SeqNum field is always populated. All remaining fields are optional.
@@ -490,8 +504,8 @@ type FetchMessageBuffer struct {
490
504
RFC822Size int64
491
505
UID imap.UID
492
506
BodyStructure imap.BodyStructure
493
- BodySection map [ * imap. FetchItemBodySection ][] byte
494
- BinarySection map [ * imap. FetchItemBinarySection ][] byte
507
+ BodySection [] FetchBodySectionBuffer
508
+ BinarySection [] FetchBinarySectionBuffer
495
509
BinarySectionSize []FetchItemDataBinarySectionSize
496
510
ModSeq uint64 // requires CONDSTORE
497
511
}
@@ -507,10 +521,10 @@ func (buf *FetchMessageBuffer) populateItemData(item FetchItemData) error {
507
521
return err
508
522
}
509
523
}
510
- if buf .BodySection == nil {
511
- buf . BodySection = make ( map [ * imap. FetchItemBodySection ][] byte )
512
- }
513
- buf . BodySection [ item . Section ] = b
524
+ buf .BodySection = append ( buf . BodySection , FetchBodySectionBuffer {
525
+ Section : item . Section ,
526
+ Bytes : b ,
527
+ })
514
528
case FetchItemDataBinarySection :
515
529
var b []byte
516
530
if item .Literal != nil {
@@ -520,10 +534,10 @@ func (buf *FetchMessageBuffer) populateItemData(item FetchItemData) error {
520
534
return err
521
535
}
522
536
}
523
- if buf .BinarySection == nil {
524
- buf . BinarySection = make ( map [ * imap. FetchItemBinarySection ][] byte )
525
- }
526
- buf . BinarySection [ item . Section ] = b
537
+ buf .BinarySection = append ( buf . BinarySection , FetchBinarySectionBuffer {
538
+ Section : item . Section ,
539
+ Bytes : b ,
540
+ })
527
541
case FetchItemDataFlags :
528
542
buf .Flags = item .Flags
529
543
case FetchItemDataEnvelope :
@@ -550,9 +564,9 @@ func (buf *FetchMessageBuffer) populateItemData(item FetchItemData) error {
550
564
//
551
565
// If the body section is not found, nil is returned.
552
566
func (buf * FetchMessageBuffer ) FindBodySection (section * imap.FetchItemBodySection ) []byte {
553
- for s , b := range buf .BodySection {
554
- if matchFetchItemBodySection (section , s ) {
555
- return b
567
+ for _ , s := range buf .BodySection {
568
+ if matchFetchItemBodySection (section , s . Section ) {
569
+ return s . Bytes
556
570
}
557
571
}
558
572
return nil
@@ -562,9 +576,9 @@ func (buf *FetchMessageBuffer) FindBodySection(section *imap.FetchItemBodySectio
562
576
//
563
577
// If the binary section is not found, nil is returned.
564
578
func (buf * FetchMessageBuffer ) FindBinarySection (section * imap.FetchItemBinarySection ) []byte {
565
- for s , b := range buf .BinarySection {
566
- if matchFetchItemBinarySection (section , s ) {
567
- return b
579
+ for _ , s := range buf .BinarySection {
580
+ if matchFetchItemBinarySection (section , s . Section ) {
581
+ return s . Bytes
568
582
}
569
583
}
570
584
return nil
0 commit comments