token AST tree does not need mutex
Этот коммит содержится в:
родитель
7e9d56a900
коммит
89cf447c8d
1 изменённых файлов: 2 добавлений и 16 удалений
|
@ -1,10 +1,6 @@
|
|||
package gherkin
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/l3pp4rd/go-behat/gherkin/lexer"
|
||||
)
|
||||
import "github.com/l3pp4rd/go-behat/gherkin/lexer"
|
||||
|
||||
type item struct {
|
||||
next, prev *item
|
||||
|
@ -13,17 +9,13 @@ type item struct {
|
|||
|
||||
type AST struct {
|
||||
head, tail *item
|
||||
mut *sync.Mutex
|
||||
}
|
||||
|
||||
func newAST() *AST {
|
||||
return &AST{mut: &sync.Mutex{}}
|
||||
return &AST{}
|
||||
}
|
||||
|
||||
func (l *AST) addTail(t *lexer.Token) *item {
|
||||
l.mut.Lock()
|
||||
defer l.mut.Unlock()
|
||||
|
||||
it := &item{next: nil, prev: l.tail, value: t}
|
||||
if l.head == nil {
|
||||
l.head = it
|
||||
|
@ -35,9 +27,6 @@ func (l *AST) addTail(t *lexer.Token) *item {
|
|||
}
|
||||
|
||||
func (l *AST) addBefore(t *lexer.Token, i *item) *item {
|
||||
l.mut.Lock()
|
||||
defer l.mut.Unlock()
|
||||
|
||||
it := &item{next: i, prev: i.prev, value: t}
|
||||
i.prev = it
|
||||
if it.prev == nil {
|
||||
|
@ -47,9 +36,6 @@ func (l *AST) addBefore(t *lexer.Token, i *item) *item {
|
|||
}
|
||||
|
||||
func (l *AST) addAfter(t *lexer.Token, i *item) *item {
|
||||
l.mut.Lock()
|
||||
defer l.mut.Unlock()
|
||||
|
||||
it := &item{next: i.next, prev: i, value: t}
|
||||
i.next = it
|
||||
if it.next == nil {
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче