Skip to content

Commit b4a936b

Browse files
committed
improve code
1 parent 4b178e1 commit b4a936b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

models/repo.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,7 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
19931993
}
19941994

19951995
releaseAttachments := make([]string, 0, 20)
1996-
attachments := make([]*Attachment, 0, len(releaseAttachments))
1996+
attachments := make([]*Attachment, 0, cap(releaseAttachments))
19971997
if err = sess.Join("INNER", "release", "release.id = attachment.release_id").
19981998
Where("release.repo_id = ?", repoID).
19991999
Find(&attachments); err != nil {
@@ -2054,7 +2054,7 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
20542054
}
20552055

20562056
attachmentPaths := make([]string, 0, 20)
2057-
attachments = make([]*Attachment, 0, len(attachmentPaths))
2057+
attachments = attachments[:0]
20582058
if err = sess.Join("INNER", "issue", "issue.id = attachment.issue_id").
20592059
Where("issue.repo_id = ?", repoID).
20602060
Find(&attachments); err != nil {
@@ -2146,10 +2146,8 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
21462146
}
21472147

21482148
// Remove release attachment files.
2149-
if len(releaseAttachments) > 0 {
2150-
for i := range releaseAttachments {
2151-
removeAllWithNotice(x, "Delete release attachment", releaseAttachments[i])
2152-
}
2149+
for i := range releaseAttachments {
2150+
removeAllWithNotice(x, "Delete release attachment", releaseAttachments[i])
21532151
}
21542152

21552153
if len(repo.Avatar) > 0 {

0 commit comments

Comments
 (0)