Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: specify the size of slice when the slice is created #6

Merged
merged 1 commit into from
Jan 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,15 @@ func snapshot() error {

prInfos := getPRInfos(prs)

var labelsTag []string
var reviewersTag []string

for _, prInfo := range prInfos {
labelsTag = []string{}
reviewersTag = []string{}

for _, label := range prInfo.Labels {
labelsTag = append(labelsTag, *label.Name)
labelsTag := make([]string, len(prInfo.Labels))
for i, label := range prInfo.Labels {
labelsTag[i] = *label.Name
}

for _, reviewer := range prInfo.RequestedReviewers {
reviewersTag = append(reviewersTag, *reviewer.Login)
reviewersTag := make([]string, len(prInfo.RequestedReviewers))
for i, reviewer := range prInfo.RequestedReviewers {
reviewersTag[i] = *reviewer.Login
}

labels := prometheus.Labels{
Expand Down Expand Up @@ -174,18 +170,18 @@ func parseRepositories(repositories string) []string {
}

func getPRInfos(prs []*github.PullRequest) []PR {
prInfos := []PR{}
prInfos := make([]PR, len(prs))

for _, pr := range prs {
for i, pr := range prs {
repos := strings.Split(*pr.URL, "/")

prInfos = append(prInfos, PR{
prInfos[i] = PR{
Number: pr.Number,
Labels: pr.Labels,
User: pr.User.Login,
RequestedReviewers: pr.RequestedReviewers,
Repo: repos[4] + "/" + repos[5],
})
}
}

return prInfos
Expand Down