code cleanup.

no need for a second copy of the data.
This commit is contained in:
boombuler 2017-06-03 14:08:06 +02:00
parent a59cf9ed0f
commit 1afd8687e3
1 changed files with 3 additions and 10 deletions

View File

@ -68,20 +68,13 @@ func Encode(content string) (barcode.Barcode, error) {
return utils.New1DCode("Code 93", content, result), nil 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 { func getChecksum(content string, maxWeight int) rune {
weight := 1 weight := 1
total := 0 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] info, ok := encodeTable[r]
if !ok { if !ok {
return ' ' return ' '