From 1afd8687e36f3b82072b322c2d7aac375bfdb704 Mon Sep 17 00:00:00 2001 From: boombuler Date: Sat, 3 Jun 2017 14:08:06 +0200 Subject: [PATCH] code cleanup. no need for a second copy of the data. --- code93/encoder.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/code93/encoder.go b/code93/encoder.go index 78613a5..43b7243 100644 --- a/code93/encoder.go +++ b/code93/encoder.go @@ -68,20 +68,13 @@ func Encode(content string) (barcode.Barcode, error) { return utils.New1DCode("Code 93", content, result), nil } -func reverse(value string) string { - data := []rune(value) - result := []rune{} - for i := len(data) - 1; i >= 0; i-- { - result = append(result, data[i]) - } - return string(result) -} - func getChecksum(content string, maxWeight int) rune { weight := 1 total := 0 - for _, r := range reverse(content) { + data := []rune(content) + for i := len(data) - 1; i >= 0; i-- { + r := data[i] info, ok := encodeTable[r] if !ok { return ' '