Skip to content

Commit c0a6309

Browse files
author
Gusted
authored
Simplify loops to copy (#19569)
- Simplify two loops into `copy` statements.
1 parent 1597e2d commit c0a6309

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

modules/setting/log.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ func GetLogDescriptions() map[string]*LogDescription {
3232
descs := make(map[string]*LogDescription, len(logDescriptions))
3333
for k, v := range logDescriptions {
3434
subLogDescriptions := make([]SubLogDescription, len(v.SubLogDescriptions))
35-
for i, s := range v.SubLogDescriptions {
36-
subLogDescriptions[i] = s
37-
}
35+
copy(subLogDescriptions, v.SubLogDescriptions)
36+
3837
descs[k] = &LogDescription{
3938
Name: v.Name,
4039
SubLogDescriptions: subLogDescriptions,

routers/api/v1/repo/language.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ func GetLanguages(ctx *context.APIContext) {
7676
}
7777

7878
resp := make(languageResponse, len(langs))
79-
for i, v := range langs {
80-
resp[i] = v
81-
}
79+
copy(resp, langs)
8280

8381
ctx.JSON(http.StatusOK, resp)
8482
}

0 commit comments

Comments
 (0)