Skip to content

Commit

Permalink
remove the need for reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
anatoly-kussul committed Nov 28, 2024
1 parent 61b4430 commit 17c915d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
18 changes: 4 additions & 14 deletions base57.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,17 @@ func (b *base57) numToString(number uint128) string {
var digit uint64
out := make([]rune, strLen)

i := 0
i := strLen - 1
for number.Hi > 0 || number.Lo > 0 {
number, digit = number.quoRem64(alphabetLen)
out[i] = b.alphabet.chars[digit]
i++
i--
}
for i < strLen {
for i >= 0 {
out[i] = b.alphabet.chars[0]
i++
i--
}

reverse(out)

return string(out)
}

Expand Down Expand Up @@ -85,11 +83,3 @@ func (b *base57) stringToNumBytes(s string) ([]byte, error) {
n.putBytes(buf)
return buf, nil
}

// reverse reverses a inline.
func reverse(a []rune) {
n := len(a)
for i := 0; i < n/2; i++ {
a[i], a[n-1-i] = a[n-1-i], a[i]
}
}
13 changes: 0 additions & 13 deletions base57_test.go

This file was deleted.

0 comments on commit 17c915d

Please # to comment.