mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect: use strings.EqualFold instead of strings.ToLower where appropriate
Strings.EqualFold doesn't allocate memory contrary to strings.ToLower if the input string contains uppercase chars
This commit is contained in:
parent
95608885ea
commit
92de6ea340
4 changed files with 10 additions and 10 deletions
|
@ -213,11 +213,11 @@ func (p *parser) parseMetricExprOrFuncCall() (Expr, error) {
|
|||
// Metric epxression or bool expression or None.
|
||||
if isBool(ident) {
|
||||
be := &BoolExpr{
|
||||
B: strings.ToLower(ident) == "true",
|
||||
B: strings.EqualFold(ident, "true"),
|
||||
}
|
||||
return be, nil
|
||||
}
|
||||
if strings.ToLower(ident) == "none" {
|
||||
if strings.EqualFold(ident, "none") {
|
||||
nne := &NoneExpr{}
|
||||
return nne, nil
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ func binaryOpNeqFunc(bfa *binaryOpFuncArg) ([]*timeseries, error) {
|
|||
}
|
||||
|
||||
func isUnionFunc(e metricsql.Expr) bool {
|
||||
if fe, ok := e.(*metricsql.FuncExpr); ok && (fe.Name == "" || strings.ToLower(fe.Name) == "union") {
|
||||
if fe, ok := e.(*metricsql.FuncExpr); ok && (fe.Name == "" || strings.EqualFold(fe.Name, "union")) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
@ -303,7 +303,7 @@ func ensureSingleTimeseries(side string, be *metricsql.BinaryOpExpr, tss []*time
|
|||
func groupJoin(singleTimeseriesSide string, be *metricsql.BinaryOpExpr, rvsLeft, rvsRight, tssLeft, tssRight []*timeseries) ([]*timeseries, []*timeseries, error) {
|
||||
joinTags := be.JoinModifier.Args
|
||||
var skipTags []string
|
||||
if strings.ToLower(be.GroupModifier.Op) == "on" {
|
||||
if strings.EqualFold(be.GroupModifier.Op, "on") {
|
||||
skipTags = be.GroupModifier.Args
|
||||
}
|
||||
joinPrefix := ""
|
||||
|
|
|
@ -542,7 +542,7 @@ func execBinaryOpArgs(qt *querytracer.Tracer, ec *EvalConfig, exprFirst, exprSec
|
|||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if len(tssFirst) == 0 && strings.ToLower(be.Op) != "or" {
|
||||
if len(tssFirst) == 0 && !strings.EqualFold(be.Op, "or") {
|
||||
// Fast path: there is no sense in executing the exprSecond when exprFirst returns an empty result,
|
||||
// since the "exprFirst op exprSecond" would return an empty result in any case.
|
||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3349
|
||||
|
@ -1168,7 +1168,7 @@ func evalInstantRollup(qt *querytracer.Tracer, ec *EvalConfig, funcName string,
|
|||
return evalExpr(qt, ec, be)
|
||||
case "rate":
|
||||
if iafc != nil {
|
||||
if strings.ToLower(iafc.ae.Name) != "sum" {
|
||||
if !strings.EqualFold(iafc.ae.Name, "sum") {
|
||||
qt.Printf("do not apply instant rollup optimization for incremental aggregate %s()", iafc.ae.Name)
|
||||
return evalAt(qt, timestamp, window)
|
||||
}
|
||||
|
@ -1214,7 +1214,7 @@ func evalInstantRollup(qt *querytracer.Tracer, ec *EvalConfig, funcName string,
|
|||
return evalExpr(qt, ec, be)
|
||||
case "max_over_time":
|
||||
if iafc != nil {
|
||||
if strings.ToLower(iafc.ae.Name) != "max" {
|
||||
if !strings.EqualFold(iafc.ae.Name, "max") {
|
||||
qt.Printf("do not apply instant rollup optimization for non-max incremental aggregate %s()", iafc.ae.Name)
|
||||
return evalAt(qt, timestamp, window)
|
||||
}
|
||||
|
@ -1276,7 +1276,7 @@ func evalInstantRollup(qt *querytracer.Tracer, ec *EvalConfig, funcName string,
|
|||
return tss, nil
|
||||
case "min_over_time":
|
||||
if iafc != nil {
|
||||
if strings.ToLower(iafc.ae.Name) != "min" {
|
||||
if !strings.EqualFold(iafc.ae.Name, "min") {
|
||||
qt.Printf("do not apply instant rollup optimization for non-min incremental aggregate %s()", iafc.ae.Name)
|
||||
return evalAt(qt, timestamp, window)
|
||||
}
|
||||
|
@ -1345,7 +1345,7 @@ func evalInstantRollup(qt *querytracer.Tracer, ec *EvalConfig, funcName string,
|
|||
"increase",
|
||||
"increase_pure",
|
||||
"sum_over_time":
|
||||
if iafc != nil && strings.ToLower(iafc.ae.Name) != "sum" {
|
||||
if iafc != nil && !strings.EqualFold(iafc.ae.Name, "sum") {
|
||||
qt.Printf("do not apply instant rollup optimization for non-sum incremental aggregate %s()", iafc.ae.Name)
|
||||
return evalAt(qt, timestamp, window)
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ func maySortResults(e metricsql.Expr) bool {
|
|||
return false
|
||||
}
|
||||
case *metricsql.BinaryOpExpr:
|
||||
if strings.ToLower(v.Op) == "or" {
|
||||
if strings.EqualFold(v.Op, "or") {
|
||||
// Do not sort results for `a or b` in the same way as Prometheus does.
|
||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4763
|
||||
return false
|
||||
|
|
Loading…
Reference in a new issue