Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a micro-optimization, which was causing a race condition. #2856

Merged
merged 2 commits into from
Dec 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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