maintner: use p.c instead of p.gr.github.c in githubRepoPoller.syncIssues
The githubRepoPoller type has a field c, which is a shortcut for
gr.github.c. Other githubRepoPoller methods use it, so start using
it in syncIssues as well.
This makes the code more consistent and easier to read.
Also remove a spurious period in GitHubRepo.newMutationFromIssue
documentation.
Change-Id: Iecebd2ba6c69e3479e8d627fea691fcf9415aa51
Reviewed-on: https://go-review.googlesource.com/c/160841
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/maintner/github.go b/maintner/github.go
index fd52f12..af6f121 100644
--- a/maintner/github.go
+++ b/maintner/github.go
@@ -1193,7 +1193,7 @@
// the corpus) and b (the current GitHub API state).
//
// If newMutationFromIssue returns nil, the provided github.Issue is no newer
-// than the data we have in the corpus. 'a'. may be nil.
+// than the data we have in the corpus. 'a' may be nil.
func (r *GitHubRepo) newMutationFromIssue(a *GitHubIssue, b *github.Issue) *maintpb.Mutation {
if b == nil || b.Number == nil {
panic(fmt.Sprintf("github issue with nil number: %#v", b))
@@ -1715,7 +1715,6 @@
}
func (p *githubRepoPoller) syncIssues(ctx context.Context, expectChanges bool) error {
- c := p.gr.github.c
page := 1
seen := make(map[int64]bool)
keepGoing := true
@@ -1767,12 +1766,12 @@
seen[id] = true
var mp *maintpb.Mutation
- c.mu.RLock()
+ p.c.mu.RLock()
{
gi := p.gr.issues[int32(*is.Number)]
mp = p.gr.newMutationFromIssue(gi, is)
}
- c.mu.RUnlock()
+ p.c.mu.RUnlock()
if mp == nil {
continue
@@ -1794,7 +1793,7 @@
changes++
p.logf("changed issue %d: %s", is.GetNumber(), is.GetTitle())
- c.addMutation(mp)
+ p.c.addMutation(mp)
p.lastUpdate = time.Now()
}
@@ -1812,9 +1811,9 @@
}
}
- c.mu.RLock()
+ p.c.mu.RLock()
num := len(p.gr.issues)
- c.mu.RUnlock()
+ p.c.mu.RUnlock()
p.logf("After page %d: %v issues, %v changes, %v issues in memory", page, len(issues), changes, num)
page++
@@ -1835,7 +1834,7 @@
NotExist: true,
},
}
- c.addMutation(mp)
+ p.c.addMutation(mp)
continue
} else if err != nil {
return err
@@ -1845,7 +1844,7 @@
continue
}
p.logf("modified issue %d: %s", issue.GetNumber(), issue.GetTitle())
- c.addMutation(mp)
+ p.c.addMutation(mp)
p.lastUpdate = time.Now()
}
}