Skip to content

Commit

Permalink
maintner: use p.c instead of p.gr.github.c in githubRepoPoller.syncIs…
Browse files Browse the repository at this point in the history
…sues

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>
  • Loading branch information
dmitshur committed Feb 13, 2019
1 parent 0985405 commit ff5c28c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions maintner/github.go
Expand Up @@ -1193,7 +1193,7 @@ func (d githubIssueDiffer) diffLockedState(m *maintpb.GithubIssueMutation) bool
// 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))
Expand Down Expand Up @@ -1715,7 +1715,6 @@ func (p *githubRepoPoller) foreachItem(
}

func (p *githubRepoPoller) syncIssues(ctx context.Context, expectChanges bool) error {
c := p.gr.github.c
page := 1
seen := make(map[int64]bool)
keepGoing := true
Expand Down Expand Up @@ -1767,12 +1766,12 @@ func (p *githubRepoPoller) syncIssues(ctx context.Context, expectChanges bool) e
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
Expand All @@ -1794,7 +1793,7 @@ func (p *githubRepoPoller) syncIssues(ctx context.Context, expectChanges bool) e

changes++
p.logf("changed issue %d: %s", is.GetNumber(), is.GetTitle())
c.addMutation(mp)
p.c.addMutation(mp)
p.lastUpdate = time.Now()
}

Expand All @@ -1812,9 +1811,9 @@ func (p *githubRepoPoller) syncIssues(ctx context.Context, expectChanges bool) e
}
}

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++
Expand All @@ -1835,7 +1834,7 @@ func (p *githubRepoPoller) syncIssues(ctx context.Context, expectChanges bool) e
NotExist: true,
},
}
c.addMutation(mp)
p.c.addMutation(mp)
continue
} else if err != nil {
return err
Expand All @@ -1845,7 +1844,7 @@ func (p *githubRepoPoller) syncIssues(ctx context.Context, expectChanges bool) e
continue
}
p.logf("modified issue %d: %s", issue.GetNumber(), issue.GetTitle())
c.addMutation(mp)
p.c.addMutation(mp)
p.lastUpdate = time.Now()
}
}
Expand Down

0 comments on commit ff5c28c

Please sign in to comment.