From f85a57052141a785b3bd28da0ca77a7a531334a3 Mon Sep 17 00:00:00 2001 From: Anatoly Kussul Date: Thu, 9 Jan 2025 09:08:38 +0100 Subject: [PATCH] use array in default encode --- encoder.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/encoder.go b/encoder.go index 42734d4..924c1b1 100644 --- a/encoder.go +++ b/encoder.go @@ -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++ { @@ -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 {