Skip to content

Commit

Permalink
Remove calls to Free and ShiftLen
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Nov 6, 2017
1 parent fc0c946 commit f49ea8b
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 31 deletions.
5 changes: 0 additions & 5 deletions css/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ func (l Lexer) Err() error {
return l.r.Err()
}

// Free frees up bytes of length n from previously shifted tokens.
func (l *Lexer) Free(n int) {
l.r.Free(n)
}

// Next returns the next Token. It returns ErrorToken when an error was encountered. Using Err() one can retrieve the error message.
func (l *Lexer) Next() (TokenType, []byte) {
switch l.r.Peek(0) {
Expand Down
1 change: 0 additions & 1 deletion css/lex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ func ExampleNewLexer() {
continue
}
out += string(data)
l.Free(len(data))
}
fmt.Println(out)
// Output: color:red;
Expand Down
5 changes: 0 additions & 5 deletions css/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ type Parser struct {
data []byte
prevWS bool
prevEnd bool
n int
}

// NewParser returns a new CSS parser from an io.Reader. isInline specifies whether this is an inline style attribute.
Expand All @@ -116,8 +115,6 @@ func (p *Parser) Err() error {

// Next returns the next Grammar. It returns ErrorGrammar when an error was encountered. Using Err() one can retrieve the error message.
func (p *Parser) Next() (GrammarType, TokenType, []byte) {
p.l.Free(p.n)
p.n = 0
p.err = nil

if p.prevEnd {
Expand All @@ -138,15 +135,13 @@ func (p *Parser) Values() []Token {
func (p *Parser) popToken(allowComment bool) (TokenType, []byte) {
p.prevWS = false
tt, data := p.l.Next()
p.n += len(data)
for tt == WhitespaceToken || tt == CommentToken {
if tt == WhitespaceToken {
p.prevWS = true
} else if allowComment && len(p.state) == 1 {
break
}
tt, data = p.l.Next()
p.n += len(data)
}
return tt, data
}
Expand Down
5 changes: 0 additions & 5 deletions html/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ func (l *Lexer) Err() error {
return l.err
}

// Free frees up bytes of length n from previously shifted tokens.
func (l *Lexer) Free(n int) {
l.r.Free(n)
}

// Next returns the next Token. It returns ErrorToken when an error was encountered. Using Err() one can retrieve the error message.
func (l *Lexer) Next() (TokenType, []byte) {
l.text = nil
Expand Down
1 change: 0 additions & 1 deletion html/lex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ func ExampleNewLexer() {
break
}
out += string(data)
l.Free(len(data))
}
fmt.Println(out)
// Output: <span class='user'>John Doe</span>
Expand Down
5 changes: 0 additions & 5 deletions js/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ func (l *Lexer) Err() error {
return l.r.Err()
}

// Free frees up bytes of length n from previously shifted tokens.
func (l *Lexer) Free(n int) {
l.r.Free(n)
}

// Next returns the next Token. It returns ErrorToken when an error was encountered. Using Err() one can retrieve the error message.
func (l *Lexer) Next() (TokenType, []byte) {
tt := UnknownToken
Expand Down
1 change: 0 additions & 1 deletion js/lex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ func ExampleNewLexer() {
break
}
out += string(data)
l.Free(len(data))
}
fmt.Println(out)
// Output: var x = 'lorem ipsum';
Expand Down
2 changes: 0 additions & 2 deletions json/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ func (p Parser) Err() error {

// Next returns the next Grammar. It returns ErrorGrammar when an error was encountered. Using Err() one can retrieve the error message.
func (p *Parser) Next() (GrammarType, []byte) {
p.r.Free(p.r.ShiftLen())

p.moveWhitespace()
c := p.r.Peek(0)
state := p.state[len(p.state)-1]
Expand Down
5 changes: 0 additions & 5 deletions xml/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ func (l *Lexer) Err() error {
return l.err
}

// Free frees up bytes of length n from previously shifted tokens.
func (l *Lexer) Free(n int) {
l.r.Free(n)
}

// Next returns the next Token. It returns ErrorToken when an error was encountered. Using Err() one can retrieve the error message.
func (l *Lexer) Next() (TokenType, []byte) {
l.text = nil
Expand Down
1 change: 0 additions & 1 deletion xml/lex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ func ExampleNewLexer() {
break
}
out += string(data)
l.Free(len(data))
}
fmt.Println(out)
// Output: <span class='user'>John Doe</span>
Expand Down

0 comments on commit f49ea8b

Please sign in to comment.