Skip to content

Commit

Permalink
refactor: use unsafe to avoid alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
wazazaby committed Mar 21, 2024
1 parent 4712c80 commit 4d59d10
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion vimebu.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"strconv"
"strings"
"unsafe"
)

const (
Expand Down Expand Up @@ -251,5 +252,10 @@ func (b *Builder) String() string {
if b.flLabel {
b.underlying.WriteByte(rightBracketByte)
}
return b.underlying.String()

return b.unsafeString()
}

func (b *Builder) unsafeString() string {
return unsafe.String(unsafe.SliceData(b.underlying.Bytes()), b.underlying.Len())
}

0 comments on commit 4d59d10

Please sign in to comment.