diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-05-03 17:04:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 17:04:23 +0800 |
commit | 772ad761eb4fa88e9912f6bf0eaed65ad3830292 (patch) | |
tree | f8355e40773227c47210a19d9b9f9cbfd0ca0d68 /models | |
parent | c8ec2261a99590f15699e9147a28e4b61c1c2ea5 (diff) | |
download | gitea-772ad761eb4fa88e9912f6bf0eaed65ad3830292.tar.gz gitea-772ad761eb4fa88e9912f6bf0eaed65ad3830292.zip |
Fix some slice problems (incorrect slice length) (#19592)
Diffstat (limited to 'models')
-rw-r--r-- | models/auth/oauth2.go | 2 | ||||
-rw-r--r-- | models/repo_activity.go | 2 | ||||
-rw-r--r-- | models/user/list.go | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/models/auth/oauth2.go b/models/auth/oauth2.go index 2341e08620..4d44a8842a 100644 --- a/models/auth/oauth2.go +++ b/models/auth/oauth2.go @@ -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) } diff --git a/models/repo_activity.go b/models/repo_activity.go index 7475be2b11..06710ff1ac 100644 --- a/models/repo_activity.go +++ b/models/repo_activity.go @@ -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) } diff --git a/models/user/list.go b/models/user/list.go index 06ec511375..5cdc92ba4a 100644 --- a/models/user/list.go +++ b/models/user/list.go @@ -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 } |