Skip to content

Commit

Permalink
Fix some slice problems (incorrect slice length) (go-gitea#19592)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored and AbdulrhmnGhanem committed Aug 23, 2022
1 parent 0b8e495 commit 4591a22
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion models/auth/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion models/repo_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion models/user/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 4591a22

Please sign in to comment.