mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
reduce addOffst to 2 parameters
Signed-off-by: schou <pschou@users.noreply.github.com>
This commit is contained in:
parent
75d932a172
commit
efbf3af05d
|
@ -383,12 +383,12 @@ paren_expr : LEFT_PAREN expr RIGHT_PAREN
|
|||
|
||||
offset_expr: expr OFFSET duration
|
||||
{
|
||||
yylex.(*parser).addOffset($1, $3, 1)
|
||||
yylex.(*parser).addOffset($1, $3)
|
||||
$$ = $1
|
||||
}
|
||||
| expr OFFSET SUB duration
|
||||
{
|
||||
yylex.(*parser).addOffset($1, $4, -1)
|
||||
yylex.(*parser).addOffset($1, -$4)
|
||||
$$ = $1
|
||||
}
|
||||
| expr OFFSET error
|
||||
|
|
|
@ -1241,14 +1241,14 @@ yydefault:
|
|||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line generated_parser.y:385
|
||||
{
|
||||
yylex.(*parser).addOffset(yyDollar[1].node, yyDollar[3].duration, 1)
|
||||
yylex.(*parser).addOffset(yyDollar[1].node, yyDollar[3].duration)
|
||||
yyVAL.node = yyDollar[1].node
|
||||
}
|
||||
case 67:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line generated_parser.y:390
|
||||
{
|
||||
yylex.(*parser).addOffset(yyDollar[1].node, yyDollar[4].duration, -1)
|
||||
yylex.(*parser).addOffset(yyDollar[1].node, -yyDollar[4].duration)
|
||||
yyVAL.node = yyDollar[1].node
|
||||
}
|
||||
case 68:
|
||||
|
|
|
@ -683,7 +683,7 @@ func (p *parser) newLabelMatcher(label Item, operator Item, value Item) *labels.
|
|||
}
|
||||
|
||||
// addOffset is used to set the offset in the generated parser.
|
||||
func (p *parser) addOffset(e Node, offset time.Duration, direction int) {
|
||||
func (p *parser) addOffset(e Node, offset time.Duration) {
|
||||
var orgoffsetp *time.Duration
|
||||
var endPosp *Pos
|
||||
|
||||
|
@ -711,7 +711,7 @@ func (p *parser) addOffset(e Node, offset time.Duration, direction int) {
|
|||
if *orgoffsetp != 0 {
|
||||
p.addParseErrf(e.PositionRange(), "offset may not be set multiple times")
|
||||
} else if orgoffsetp != nil {
|
||||
*orgoffsetp = offset * time.Duration(direction)
|
||||
*orgoffsetp = offset
|
||||
}
|
||||
|
||||
*endPosp = p.lastClosing
|
||||
|
|
Loading…
Reference in a new issue