Skip to content

Commit

Permalink
use array in default encode
Browse files Browse the repository at this point in the history
  • Loading branch information
anatoly-kussul committed Jan 9, 2025
1 parent 43645fa commit f85a570
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (e encoder) Encode(u uuid.UUID) string {
func (e encoder) defaultEncode(num uint128) string { // compiler optimizes a lot of divisions by constant
var i int
var r uint64
buf := make([]byte, defaultEncLen)
var buf [defaultEncLen]byte
for i = defaultEncLen - 1; num.Hi > 0 || num.Lo > 0; {
num, r = num.quoRem64(defaultDivisor)
for j := 0; j < defaultNDigits && i >= 0; j++ {
Expand All @@ -60,7 +60,7 @@ func (e encoder) defaultEncode(num uint128) string { // compiler optimizes a lot
for ; i >= 0; i-- {
buf[i] = byte(e.alphabet.chars[0])
}
return string(buf)
return string(buf[:])
}

func (e encoder) encode(num uint128) string {
Expand Down

0 comments on commit f85a570

Please sign in to comment.