OpenMetrics parse: avoid setting prev token (#6781)

We can avoid setting a prev token in the OM parser. The previous
coundition that checked for prev was unreacheable.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
Julien Pivotto 2020-02-07 08:33:26 +01:00 committed by GitHub
parent 22a04239c9
commit 40b66d29ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 8 deletions

View File

@ -90,7 +90,6 @@ type OpenMetricsParser struct {
hasTS bool
start int
offsets []int
prev token
eOffsets []int
exemplar []byte
@ -233,19 +232,14 @@ func (p *OpenMetricsParser) Next() (Entry, error) {
p.exemplarVal = 0
p.hasExemplarTs = false
t := p.nextToken()
defer func() { p.prev = t }()
switch t {
switch t := p.nextToken(); t {
case tEofWord:
if t := p.nextToken(); t != tEOF {
return EntryInvalid, errors.New("unexpected data after # EOF")
}
return EntryInvalid, io.EOF
case tEOF:
if p.prev != tEofWord {
return EntryInvalid, errors.New("data does not end with # EOF")
}
return EntryInvalid, io.EOF
return EntryInvalid, errors.New("data does not end with # EOF")
case tHelp, tType, tUnit:
switch t := p.nextToken(); t {
case tMName: