Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
* don't skip decides based on stop_at
* don't push explore context into parse context for parsing condition
  • Loading branch information
willscott committed Aug 3, 2021
1 parent 465fafb commit bcfe881
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions traversal/selector/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
func (c *Condition) Match(n ipld.Node) bool {
switch c.mode {
case ConditionMode_Link:
if n.Kind() != ipld.Kind_Link || c.match.Kind() != ipld.Kind_Link {
if n.Kind() != ipld.Kind_Link {
return false
}
lnk, err := n.AsLink()
Expand Down Expand Up @@ -65,7 +65,7 @@ func (pc ParseContext) ParseCondition(n ipld.Node) (Condition, error) {
switch ConditionMode(kstr) {
case ConditionMode_Link:
if _, err := v.AsLink(); err != nil {
return Condition{}, fmt.Errorf("selector spec parse rejected: condition_link must be a link")
return Condition{}, fmt.Errorf("selector spec parse rejected: conditionlink must be a link")
}
return Condition{mode: ConditionMode_Link, match: v}, nil
default:
Expand Down
5 changes: 1 addition & 4 deletions traversal/selector/exploreRecursive.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ func (s ExploreRecursive) replaceRecursiveEdge(nextSelector Selector, replacemen

// Decide if a node directly matches
func (s ExploreRecursive) Decide(n ipld.Node) bool {
if s.stopAt != nil && s.stopAt.Match(n) {
return false
}
return s.current.Decide(n)
}

Expand Down Expand Up @@ -203,7 +200,7 @@ func (pc ParseContext) ParseExploreRecursive(n ipld.Node) (Selector, error) {
var stopCondition *Condition
stop, err := n.LookupByString(SelectorKey_StopAt)
if err == nil {
condition, err := pc.PushParent(erc).ParseCondition(stop)
condition, err := pc.ParseCondition(stop)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit bcfe881

Please sign in to comment.