Reduced memory allocations

This commit is contained in:
Eduard Urbach 2024-07-17 21:09:01 +02:00
parent 4806206500
commit bdb9312743
Signed by: eduard
GPG key ID: 49226B848C78F6C8

View file

@ -1,6 +1,9 @@
package token
import "fmt"
import (
"fmt"
"unsafe"
)
// Token represents a single element in a source file.
// The characters that make up an identifier are grouped into a single token.
@ -30,5 +33,5 @@ func (t *Token) Reset() {
// Text returns the token text.
func (t *Token) Text() string {
return string(t.Bytes)
return unsafe.String(unsafe.SliceData(t.Bytes), len(t.Bytes))
}