Skip to content

Commit

Permalink
Simplify loops to copy (go-gitea#19569)
Browse files Browse the repository at this point in the history
- Simplify two loops into `copy` statements.
  • Loading branch information
Gusted authored and AbdulrhmnGhanem committed Aug 23, 2022
1 parent cb7af7e commit af3d651
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 2 additions & 3 deletions modules/setting/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ func GetLogDescriptions() map[string]*LogDescription {
descs := make(map[string]*LogDescription, len(logDescriptions))
for k, v := range logDescriptions {
subLogDescriptions := make([]SubLogDescription, len(v.SubLogDescriptions))
for i, s := range v.SubLogDescriptions {
subLogDescriptions[i] = s
}
copy(subLogDescriptions, v.SubLogDescriptions)

descs[k] = &LogDescription{
Name: v.Name,
SubLogDescriptions: subLogDescriptions,
Expand Down
4 changes: 1 addition & 3 deletions routers/api/v1/repo/language.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ func GetLanguages(ctx *context.APIContext) {
}

resp := make(languageResponse, len(langs))
for i, v := range langs {
resp[i] = v
}
copy(resp, langs)

ctx.JSON(http.StatusOK, resp)
}

0 comments on commit af3d651

Please sign in to comment.