Skip to content

Commit

Permalink
cleaner recurseParents() implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronO committed Aug 12, 2020
1 parent 15e9a1a commit 6043b12
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions internal/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,12 @@ func (r *resolver) resolveWithoutSymlinks(sourceDir string, importPath string) (

// recurseParents recursively walks up the dirInfo hierarchy (child -> parent)
// the walker func returns true to stop (i.e: match found) and false to continue
func (r *resolver) recurseParents(current *dirInfo, walker func(*dirInfo) bool) bool {
cursor := current

for cursor != nil {
if matched := walker(cursor); matched {
func (r *resolver) recurseParents(dirInfo *dirInfo, walker func(*dirInfo) bool) bool {
for info := dirInfo; info != nil; info = info.parent {
if matched := walker(info); matched {
return true
}
cursor = cursor.parent
}

return false
}

Expand Down

0 comments on commit 6043b12

Please sign in to comment.