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