0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 23:33:15 -05:00

Fix some slice problems (incorrect slice length) (#19592)

This commit is contained in:
Lunny Xiao 2022-05-03 17:04:23 +08:00 committed by GitHub
parent c8ec2261a9
commit 772ad761eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View file

@ -245,7 +245,7 @@ func deleteOAuth2Application(sess db.Engine, id, userid int64) error {
"oauth2_authorization_code.grant_id = oauth2_grant.id AND oauth2_grant.application_id = ?", id).Find(&codes); err != nil {
return err
}
codeIDs := make([]int64, 0)
codeIDs := make([]int64, 0, len(codes))
for _, grant := range codes {
codeIDs = append(codeIDs, grant.ID)
}

View file

@ -127,7 +127,7 @@ func GetActivityStatsTopAuthors(ctx context.Context, repo *repo_model.Repository
user.Commits += v.Commits
}
}
v := make([]*ActivityAuthorData, 0)
v := make([]*ActivityAuthorData, 0, len(users))
for _, u := range users {
v = append(v, u)
}

View file

@ -17,7 +17,7 @@ type UserList []*User //revive:disable-line:exported
// GetUserIDs returns a slice of user's id
func (users UserList) GetUserIDs() []int64 {
userIDs := make([]int64, len(users))
userIDs := make([]int64, 0, len(users))
for _, user := range users {
userIDs = append(userIDs, user.ID) // Considering that user id are unique in the list
}