From f617e115cd3320ccbf76f087588a595d325073c8 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 17 Jul 2024 21:09:01 +0200 Subject: [PATCH] Reduced memory allocations --- src/build/token/Token.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/build/token/Token.go b/src/build/token/Token.go index e10f8bc..bf1208b 100644 --- a/src/build/token/Token.go +++ b/src/build/token/Token.go @@ -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)) }