From 0318c80d335f26f508bf5a4bac14a0dbe05e87d2 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 13 Jan 2021 17:00:03 +1100 Subject: [PATCH] Dont use pointer for recursive prefs (avoid nil) --- pkg/yqlib/expression_tokeniser.go | 4 ++-- pkg/yqlib/operator_multiply.go | 2 +- pkg/yqlib/operator_recursive_descent.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/yqlib/expression_tokeniser.go b/pkg/yqlib/expression_tokeniser.go index 658ae45e..46ff1d42 100644 --- a/pkg/yqlib/expression_tokeniser.go +++ b/pkg/yqlib/expression_tokeniser.go @@ -221,10 +221,10 @@ func initLexer() (*lex.Lexer, error) { lexer.Add([]byte(`\)`), literalToken(closeBracket, true)) lexer.Add([]byte(`\.\[`), literalToken(traverseArrayCollect, false)) - lexer.Add([]byte(`\.\.`), opTokenWithPrefs(recursiveDescentOpType, nil, &recursiveDescentPreferences{RecurseArray: true, + lexer.Add([]byte(`\.\.`), opTokenWithPrefs(recursiveDescentOpType, nil, recursiveDescentPreferences{RecurseArray: true, TraversePreferences: traversePreferences{DontFollowAlias: true, IncludeMapKeys: false}})) - lexer.Add([]byte(`\.\.\.`), opTokenWithPrefs(recursiveDescentOpType, nil, &recursiveDescentPreferences{RecurseArray: true, + lexer.Add([]byte(`\.\.\.`), opTokenWithPrefs(recursiveDescentOpType, nil, recursiveDescentPreferences{RecurseArray: true, TraversePreferences: traversePreferences{DontFollowAlias: true, IncludeMapKeys: true}})) lexer.Add([]byte(`,`), opToken(unionOpType)) diff --git a/pkg/yqlib/operator_multiply.go b/pkg/yqlib/operator_multiply.go index 2c36fcb5..1cfd14a1 100644 --- a/pkg/yqlib/operator_multiply.go +++ b/pkg/yqlib/operator_multiply.go @@ -80,7 +80,7 @@ func mergeObjects(d *dataTreeNavigator, lhs *CandidateNode, rhs *CandidateNode, var results = list.New() // shouldn't recurse arrays if appending - prefs := &recursiveDescentPreferences{RecurseArray: !shouldAppendArrays, + prefs := recursiveDescentPreferences{RecurseArray: !shouldAppendArrays, TraversePreferences: traversePreferences{DontFollowAlias: true}} err := recursiveDecent(d, results, nodeToMap(rhs), prefs) if err != nil { diff --git a/pkg/yqlib/operator_recursive_descent.go b/pkg/yqlib/operator_recursive_descent.go index 962e8e41..ac08eaa1 100644 --- a/pkg/yqlib/operator_recursive_descent.go +++ b/pkg/yqlib/operator_recursive_descent.go @@ -14,7 +14,7 @@ type recursiveDescentPreferences struct { func recursiveDescentOperator(d *dataTreeNavigator, matchMap *list.List, expressionNode *ExpressionNode) (*list.List, error) { var results = list.New() - preferences := expressionNode.Operation.Preferences.(*recursiveDescentPreferences) + preferences := expressionNode.Operation.Preferences.(recursiveDescentPreferences) err := recursiveDecent(d, results, matchMap, preferences) if err != nil { return nil, err @@ -23,7 +23,7 @@ func recursiveDescentOperator(d *dataTreeNavigator, matchMap *list.List, express return results, nil } -func recursiveDecent(d *dataTreeNavigator, results *list.List, matchMap *list.List, preferences *recursiveDescentPreferences) error { +func recursiveDecent(d *dataTreeNavigator, results *list.List, matchMap *list.List, preferences recursiveDescentPreferences) error { for el := matchMap.Front(); el != nil; el = el.Next() { candidate := el.Value.(*CandidateNode)