Reduced memory allocations
This commit is contained in:
parent
68e21c96e3
commit
f617e115cd
@ -1,6 +1,9 @@
|
|||||||
package token
|
package token
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
// Token represents a single element in a source file.
|
// Token represents a single element in a source file.
|
||||||
// The characters that make up an identifier are grouped into a single token.
|
// 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.
|
// Text returns the token text.
|
||||||
func (t *Token) Text() string {
|
func (t *Token) Text() string {
|
||||||
return string(t.Bytes)
|
return unsafe.String(unsafe.SliceData(t.Bytes), len(t.Bytes))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user