Simplify loops to copy (#19569)

- Simplify two loops into `copy` statements.
pull/19557/head
Gusted 3 years ago committed by GitHub
parent 1597e2da3e
commit c0a6309a5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      modules/setting/log.go
  2. 4
      routers/api/v1/repo/language.go

@ -32,9 +32,8 @@ func GetLogDescriptions() map[string]*LogDescription {
descs := make(map[string]*LogDescription, len(logDescriptions)) descs := make(map[string]*LogDescription, len(logDescriptions))
for k, v := range logDescriptions { for k, v := range logDescriptions {
subLogDescriptions := make([]SubLogDescription, len(v.SubLogDescriptions)) subLogDescriptions := make([]SubLogDescription, len(v.SubLogDescriptions))
for i, s := range v.SubLogDescriptions { copy(subLogDescriptions, v.SubLogDescriptions)
subLogDescriptions[i] = s
}
descs[k] = &LogDescription{ descs[k] = &LogDescription{
Name: v.Name, Name: v.Name,
SubLogDescriptions: subLogDescriptions, SubLogDescriptions: subLogDescriptions,

@ -76,9 +76,7 @@ func GetLanguages(ctx *context.APIContext) {
} }
resp := make(languageResponse, len(langs)) resp := make(languageResponse, len(langs))
for i, v := range langs { copy(resp, langs)
resp[i] = v
}
ctx.JSON(http.StatusOK, resp) ctx.JSON(http.StatusOK, resp)
} }

Loading…
Cancel
Save