Skip to content

Commit

Permalink
Replace bytes.buffer with strings.builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Mido-sys committed Aug 6, 2024
1 parent 8eb5406 commit 79fe842
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions compiler.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package plush

import (
"bytes"
"fmt"

"github.com/gobuffalo/plush/v4/token"
Expand Down Expand Up @@ -36,7 +35,7 @@ type compiler struct {
}

func (c *compiler) compile() (string, error) {
bb := &bytes.Buffer{}
bb := &strings.Builder{}

for _, stmt := range c.program.Statements {
var res interface{}
Expand Down Expand Up @@ -70,7 +69,7 @@ func (c *compiler) compile() (string, error) {
return bb.String(), nil
}

func (c *compiler) write(bb *bytes.Buffer, i interface{}) {
func (c *compiler) write(bb *strings.Builder, i interface{}) {
switch t := i.(type) {
case time.Time:
if dtf, ok := c.ctx.Value("TIME_FORMAT").(string); ok {
Expand Down
4 changes: 2 additions & 2 deletions helpers.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package plush

import (
"bytes"
"fmt"
"strings"
"sync"

"github.com/gobuffalo/helpers"
Expand Down Expand Up @@ -80,7 +80,7 @@ func (h HelperContext) BlockWith(hc hctx.Context) (string, error) {
return "", err
}

bb := &bytes.Buffer{}
bb := &strings.Builder{}
h.compiler.write(bb, i)

return bb.String(), nil
Expand Down

0 comments on commit 79fe842

Please sign in to comment.