11package goquery
22
33import (
4- "bytes"
54 "regexp"
65 "strings"
76
@@ -60,14 +59,14 @@ func (s *Selection) SetAttr(attrName, val string) *Selection {
6059// Text gets the combined text contents of each element in the set of matched
6160// elements, including their descendants.
6261func (s * Selection ) Text () string {
63- var buf bytes. Buffer
62+ var builder strings. Builder
6463
6564 // Slightly optimized vs calling Each: no single selection object created
6665 var f func (* html.Node )
6766 f = func (n * html.Node ) {
6867 if n .Type == html .TextNode {
6968 // Keep newlines and spaces, like jQuery
70- buf .WriteString (n .Data )
69+ builder .WriteString (n .Data )
7170 }
7271 if n .FirstChild != nil {
7372 for c := n .FirstChild ; c != nil ; c = c .NextSibling {
@@ -79,7 +78,7 @@ func (s *Selection) Text() string {
7978 f (n )
8079 }
8180
82- return buf .String ()
81+ return builder .String ()
8382}
8483
8584// Size is an alias for Length.
@@ -97,16 +96,16 @@ func (s *Selection) Length() int {
9796func (s * Selection ) Html () (ret string , e error ) {
9897 // Since there is no .innerHtml, the HTML content must be re-created from
9998 // the nodes using html.Render.
100- var buf bytes. Buffer
99+ var builder strings. Builder
101100
102101 if len (s .Nodes ) > 0 {
103102 for c := s .Nodes [0 ].FirstChild ; c != nil ; c = c .NextSibling {
104- e = html .Render (& buf , c )
103+ e = html .Render (& builder , c )
105104 if e != nil {
106105 return
107106 }
108107 }
109- ret = buf .String ()
108+ ret = builder .String ()
110109 }
111110
112111 return
0 commit comments