#27 reduce memory allocations for scanner.Token by using sync.Pool

This commit is contained in:
z7zmey
2018-06-11 02:41:12 +03:00
parent 43451a070f
commit 2737e98559
14 changed files with 5631 additions and 1414 deletions

View File

@@ -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,
}
}

View File

@@ -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)