Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 9f2b94e

Browse files
committed
gps: create trie only when wildcard is found
* Create trie only when wildcard is found * Rename 'recursive' to 'wildcard' ignore
1 parent 5d7bc34 commit 9f2b94e

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

internal/gps/pkgtree/pkgtree.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
radix "github.com/armon/go-radix"
2121
)
2222

23-
// recursive ignore suffix
24-
const recIgnoreSuffix = "/*"
23+
// wildcard ignore suffix
24+
const wcIgnoreSuffix = "*"
2525

2626
// Package represents a Go package. It contains a subset of the information
2727
// go/build.Package does.
@@ -450,11 +450,16 @@ func (t PackageTree) ToReachMap(main, tests, backprop bool, ignore map[string]bo
450450
ignore = make(map[string]bool)
451451
}
452452

453-
// Create a radix tree for ignore prefixes
454-
xt := radix.New()
453+
// Declare a radix tree for ignore prefixes
454+
var xt *radix.Tree
455+
455456
for i := range ignore {
456-
if strings.HasSuffix(i, recIgnoreSuffix) {
457-
i = strings.TrimSuffix(i, recIgnoreSuffix)
457+
if strings.HasSuffix(i, wcIgnoreSuffix) {
458+
// Create trie if it doesn't exists
459+
if xt == nil {
460+
xt = radix.New()
461+
}
462+
i = strings.TrimSuffix(i, wcIgnoreSuffix)
458463
xt.Insert(i, true)
459464
}
460465
}

internal/gps/solver.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717
"github.com/golang/dep/internal/gps/pkgtree"
1818
)
1919

20-
// recursive ignore suffix
21-
const recIgnoreSuffix = "/*"
20+
// wildcard ignore suffix
21+
const wcIgnoreSuffix = "*"
2222

2323
var rootRev = Revision("")
2424

@@ -1345,13 +1345,17 @@ func pa2lp(pa atom, pkgs map[string]struct{}) LockedProject {
13451345
}
13461346

13471347
func createIgnorePrefixTree(ig map[string]bool) *radix.Tree {
1348-
xt := radix.New()
1348+
var xt *radix.Tree
13491349

13501350
for i := range ig {
13511351
// Check if it's a recursive ignore
1352-
if strings.HasSuffix(i, recIgnoreSuffix) {
1352+
if strings.HasSuffix(i, wcIgnoreSuffix) {
1353+
// Create trie if it doesn't exists
1354+
if xt == nil {
1355+
xt = radix.New()
1356+
}
13531357
// Create the ignore prefix and insert in the radix tree
1354-
i = strings.TrimSuffix(i, recIgnoreSuffix)
1358+
i = strings.TrimSuffix(i, wcIgnoreSuffix)
13551359
xt.Insert(i, true)
13561360
}
13571361
}

0 commit comments

Comments
 (0)