From b0bb644edefca7e59eb5cc8af994350c0eb34d7b Mon Sep 17 00:00:00 2001 From: Manish R Jain Date: Sun, 30 Dec 2018 08:48:28 -0800 Subject: [PATCH] Remove a micro-optimization, which was causing a race condition. --- worker/task.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/worker/task.go b/worker/task.go index fa36f74d3a3..9aa68abdcbb 100644 --- a/worker/task.go +++ b/worker/task.go @@ -1505,14 +1505,10 @@ func applyFacetsTree(postingFacets []*api.Facet, ftree *facetsTree) (bool, error return false, err } - v, has := ftree.function.convertedVal[typId] - if !has { - if v, err = types.Convert(ftree.function.val, typId); err != nil { - // ignore facet if not of appropriate type - return false, nil - } else { - ftree.function.convertedVal[typId] = v - } + v, err := types.Convert(ftree.function.val, typId) + if err != nil { + // ignore facet if not of appropriate type + return false, nil } fVal, err := facets.ValFor(fc) if err != nil { @@ -1599,8 +1595,6 @@ type facetsFunc struct { args []string tokens []string val types.Val - // convertedVal is used to cache the converted value of val for each type - convertedVal map[types.TypeID]types.Val } type facetsTree struct { op string @@ -1616,7 +1610,6 @@ func preprocessFilter(tree *pb.FilterTree) (*facetsTree, error) { ftree.op = tree.Op if tree.Func != nil { ftree.function = &facetsFunc{} - ftree.function.convertedVal = make(map[types.TypeID]types.Val) ftree.function.name = tree.Func.Name ftree.function.key = tree.Func.Key ftree.function.args = tree.Func.Args