mirror of
https://github.com/prometheus/prometheus
synced 2024-12-24 23:42:32 +00:00
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
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user