Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxincs committed Nov 28, 2023
1 parent a267567 commit b865a48
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion inference/primitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ type primitivizer struct {
// curDir is the current working directory, which is used to trim the prefix (e.g., random
// sandbox prefix if using bazel) from the file names for cross-package references.
curDir string
// objPathEncoder is used to encode object paths, which amortizes the cost of encoding the
// paths of multiple objects.
objPathEncoder *objectpath.Encoder
}

// newPrimitivizer returns a new and properly-initialized primitivizer.
Expand Down Expand Up @@ -172,6 +175,7 @@ func newPrimitivizer(pass *analysis.Pass) *primitivizer {
pass: pass,
upstreamObjPositions: upstreamObjPositions,
curDir: cwd,
objPathEncoder: &objectpath.Encoder{},
}
}

Expand All @@ -193,7 +197,7 @@ func (p *primitivizer) fullTrigger(trigger annotation.FullTrigger) primitiveFull

// site returns the primitive version of the annotation site.
func (p *primitivizer) site(key annotation.Key, isDeep bool) primitiveSite {
objPath, err := objectpath.For(key.Object())
objPath, err := p.objPathEncoder.For(key.Object())
if err != nil {
// An error will occur when trying to get object path for unexported objects, in which case
// we simply assign an empty object path.
Expand Down

0 comments on commit b865a48

Please sign in to comment.