#27 reduce memory allocations for scanner.Token by using sync.Pool
This commit is contained in:
@@ -17,7 +17,7 @@ type Error struct {
|
||||
func NewError(msg string, t *scanner.Token) *Error {
|
||||
return &Error{
|
||||
Msg: msg,
|
||||
Pos: t.Position(),
|
||||
Pos: t.Position,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,10 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
||||
|
||||
func TestConstructor(t *testing.T) {
|
||||
pos := position.NewPosition(1, 2, 3, 4)
|
||||
token := scanner.NewToken(`test`, pos)
|
||||
token := &scanner.Token{
|
||||
Value: `test`,
|
||||
Position: pos,
|
||||
}
|
||||
|
||||
actual := errors.NewError("message", token)
|
||||
|
||||
@@ -41,7 +44,10 @@ func TestConstructor(t *testing.T) {
|
||||
|
||||
func TestPrint(t *testing.T) {
|
||||
pos := position.NewPosition(1, 2, 3, 4)
|
||||
token := scanner.NewToken(`test`, pos)
|
||||
token := &scanner.Token{
|
||||
Value: `test`,
|
||||
Position: pos,
|
||||
}
|
||||
|
||||
Error := errors.NewError("message", token)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user