Skip to content

Commit

Permalink
Remove a micro-optimization, which was causing a race condition. (#2856)
Browse files Browse the repository at this point in the history
Fix for #2849 .
  • Loading branch information
manishrjain authored Dec 31, 2018
1 parent bc8750a commit 787799b
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions worker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -1496,14 +1496,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 {
Expand Down Expand Up @@ -1590,8 +1586,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
Expand All @@ -1607,7 +1601,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
Expand Down

0 comments on commit 787799b

Please sign in to comment.