From e209901fef2a1297ee2ea815fd2332af1a4ec411 Mon Sep 17 00:00:00 2001 From: Las Zenow Date: Wed, 22 Aug 2012 10:37:48 +0200 Subject: [PATCH] Use arrays properly when known the lenght --- upload.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/upload.go b/upload.go index 01e56aa..7b5bb53 100644 --- a/upload.go +++ b/upload.go @@ -149,17 +149,17 @@ func getCover(e *epub.Epub, title string) (string, string) { func parseAuthr(creator []string) []string { exp1, _ := regexp.Compile("^(.*\\( *([^\\)]*) *\\))*$") exp2, _ := regexp.Compile("^[^:]*: *(.*)$") - var res []string //TODO: can be predicted the lenght - for _, s := range creator { + res := make([]string, len(creator)) + for i, s := range creator { auth := exp1.FindStringSubmatch(s) if auth != nil { - res = append(res, cleanStr(strings.Join(auth[2:], ", "))) + res[i] = cleanStr(strings.Join(auth[2:], ", ")) } else { auth := exp2.FindStringSubmatch(s) if auth != nil { - res = append(res, cleanStr(auth[1])) + res[i] = cleanStr(auth[1]) } else { - res = append(res, cleanStr(s)) + res[i] = cleanStr(s) } } }