Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
AsaiYusuke committed Jan 20, 2023
1 parent 0b02fd4 commit de2e4bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
14 changes: 6 additions & 8 deletions jsonpath_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,17 +621,15 @@ func (p *jsonPathParser) pushCompareParameterLiteral(text interface{}) {
}

func (p *jsonPathParser) pushCompareParameterRoot(node syntaxNode) {
param := &syntaxQueryParamRoot{
p.updateAccessorMode(node, false)
p.push(&syntaxQueryParamRoot{
param: node,
}
p.updateAccessorMode(param.param, false)
p.push(param)
})
}

func (p *jsonPathParser) pushCompareParameterCurrentRoot(node syntaxNode) {
param := &syntaxQueryParamCurrentRoot{
p.updateAccessorMode(node, false)
p.push(&syntaxQueryParamCurrentRoot{
param: node,
}
p.updateAccessorMode(param.param, false)
p.push(param)
})
}
9 changes: 4 additions & 5 deletions syntax_query_param_current_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ func (e *syntaxQueryParamCurrentRoot) compute(
root interface{}, currentList []interface{}, container *bufferContainer) []interface{} {

result := make([]interface{}, len(currentList))
containers := make([]bufferContainer, len(currentList))

var hasValue bool
for index := range currentList {
values := bufferContainer{}

if err := e.param.retrieve(root, currentList[index], &values); err != nil {
if err := e.param.retrieve(root, currentList[index], &containers[index]); err != nil {
result[index] = struct{}{}
continue
}
hasValue = true
if e.param.isValueGroup() {
result[index] = values.result
result[index] = containers[index].result
} else {
result[index] = values.result[0]
result[index] = containers[index].result[0]
}
}
if hasValue {
Expand Down

0 comments on commit de2e4bc

Please sign in to comment.