From c0a6309a5f62a4947788baa29df9a03e80607f51 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 30 Apr 2022 23:53:56 +0000 Subject: [PATCH] Simplify loops to copy (#19569) - Simplify two loops into `copy` statements. --- modules/setting/log.go | 5 ++--- routers/api/v1/repo/language.go | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/setting/log.go b/modules/setting/log.go index e666e2a0274..008a419b09d 100644 --- a/modules/setting/log.go +++ b/modules/setting/log.go @@ -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, diff --git a/routers/api/v1/repo/language.go b/routers/api/v1/repo/language.go index 427a8fd6b54..f47b0a0e788 100644 --- a/routers/api/v1/repo/language.go +++ b/routers/api/v1/repo/language.go @@ -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) }