From 3a5baff88dde4bfd06a9456ec17e830b83d6928a Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Fri, 27 Mar 2015 22:52:54 -0700 Subject: [PATCH] Avoid multi-line if with a switch --- database.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/database.go b/database.go index a02d97ae0a..a26b8cd795 100644 --- a/database.go +++ b/database.go @@ -404,15 +404,16 @@ func (m *Measurement) idsForExpr(n *influxql.BinaryExpr) (seriesIDs, bool, influ func (m *Measurement) walkWhereForSeriesIds(expr influxql.Expr, filters map[uint32]influxql.Expr) (seriesIDs, bool, influxql.Expr) { switch n := expr.(type) { case *influxql.BinaryExpr: - // if it's EQ then it's either a field expression or against a tag. we can return this - if n.Op == influxql.EQ || n.Op == influxql.LT || n.Op == influxql.LTE || n.Op == influxql.GT || - n.Op == influxql.GTE || n.Op == influxql.NEQ || n.Op == influxql.EQREGEX || n.Op == influxql.NEQREGEX { + switch n.Op { + case influxql.EQ, influxql.NEQ, influxql.LT, influxql.LTE, influxql.GT, influxql.GTE, influxql.EQREGEX, influxql.NEQREGEX: + // if it's a compare, then it's either a field expression or against a tag. we can return this ids, shouldInclude, expr := m.idsForExpr(n) for _, id := range ids { filters[id] = expr } return ids, shouldInclude, expr - } else if n.Op == influxql.AND || n.Op == influxql.OR { // if it's an AND or OR we need to union or intersect the results + case influxql.AND, influxql.OR: + // if it's an AND or OR we need to union or intersect the results var ids seriesIDs l, il, lexpr := m.walkWhereForSeriesIds(n.LHS, filters) r, ir, rexpr := m.walkWhereForSeriesIds(n.RHS, filters)