@@ -612,15 +612,15 @@ func (d *Deck) applyParagraphsRequests(objectID string, paragraphs []*Paragraph)
612612
613613 bulletRanges := map [int ]* bulletRange {}
614614 count := int64 (0 )
615- text := ""
615+ var textBuilder strings. Builder
616616 bulletStartIndex := int64 (0 ) // reset per body
617617 bulletEndIndex := int64 (0 ) // reset per body
618618 currentBullet := BulletNone
619619 for j , paragraph := range paragraphs {
620620 plen := 0
621621 if paragraph .Bullet != BulletNone {
622622 if paragraph .Nesting > 0 {
623- text += strings .Repeat ("\t " , paragraph .Nesting )
623+ textBuilder . WriteString ( strings .Repeat ("\t " , paragraph .Nesting ) )
624624 plen += paragraph .Nesting
625625 }
626626 }
@@ -647,11 +647,11 @@ func (d *Deck) applyParagraphsRequests(objectID string, paragraphs []*Paragraph)
647647 })
648648 }
649649 plen += flen
650- text += fValue
650+ textBuilder . WriteString ( fValue )
651651 }
652652
653653 if len (paragraphs ) > j + 1 {
654- text += "\n "
654+ textBuilder . WriteString ( "\n " )
655655 plen ++
656656 }
657657
@@ -675,7 +675,7 @@ func (d *Deck) applyParagraphsRequests(objectID string, paragraphs []*Paragraph)
675675 reqs = append (reqs , & slides.Request {
676676 InsertText : & slides.InsertTextRequest {
677677 ObjectId : objectID ,
678- Text : text ,
678+ Text : textBuilder . String () ,
679679 },
680680 })
681681 var bulletRangeSlice []* bulletRange
@@ -840,7 +840,7 @@ func (d *Deck) updateLayout(ctx context.Context, index int, slide *Slide) (err e
840840
841841 var paragraphInfos []paragraphInfo
842842 currentIndex := int64 (0 )
843- text := ""
843+ var textBuilder strings. Builder
844844 shapeObjectID := fmt .Sprintf ("shape-%s" , uuid .New ().String ())
845845
846846 for _ , textElement := range element .Shape .Text .TextElements {
@@ -864,12 +864,12 @@ func (d *Deck) updateLayout(ctx context.Context, index int, slide *Slide) (err e
864864 if paragraphInfos [len (paragraphInfos )- 1 ].nestingLevel > 0 {
865865 // Add tabs for nesting
866866 tabs := strings .Repeat ("\t " , int (paragraphInfos [len (paragraphInfos )- 1 ].nestingLevel ))
867- text += tabs
867+ textBuilder . WriteString ( tabs )
868868 currentIndex += int64 (countString (tabs ))
869869 }
870870 }
871871
872- text += runText
872+ textBuilder . WriteString ( runText )
873873
874874 // Adjust style indices based on actual position in new text
875875 if textElement .TextRun .Style != nil {
@@ -922,7 +922,7 @@ func (d *Deck) updateLayout(ctx context.Context, index int, slide *Slide) (err e
922922 insertReqs = append (insertReqs , & slides.Request {
923923 InsertText : & slides.InsertTextRequest {
924924 ObjectId : shapeObjectID ,
925- Text : strings .TrimSuffix (text , "\n " ),
925+ Text : strings .TrimSuffix (textBuilder . String () , "\n " ),
926926 },
927927 })
928928
0 commit comments