diff --git a/encoder.go b/encoder.go index e3b9199..42734d4 100644 --- a/encoder.go +++ b/encoder.go @@ -66,7 +66,7 @@ func (e encoder) defaultEncode(num uint128) string { // compiler optimizes a lot func (e encoder) encode(num uint128) string { var r, ind uint64 i := int(e.alphabet.encLen - 1) - buf := make([]byte, int64(e.alphabet.encLen*e.alphabet.maxBytes)) + buf := make([]byte, int64(e.alphabet.encLen)*int64(e.alphabet.maxBytes)) lastPlaced := len(buf) l := uint64(e.alphabet.len) d, n := maxPow(l) diff --git a/shortuuid.go b/shortuuid.go index ee7bfcd..daad857 100644 --- a/shortuuid.go +++ b/shortuuid.go @@ -61,8 +61,7 @@ func hashedUUID(space uuid.UUID, data string) (u uuid.UUID) { h := sha1.New() h.Write(space[:]) //nolint:errcheck h.Write(unsafe.Slice(unsafe.StringData(data), len(data))) //nolint:errcheck - buf := make([]byte, 0, sha1.Size) - s := h.Sum(buf) + s := h.Sum(make([]byte, 0, sha1.Size)) copy(u[:], s) u[6] = (u[6] & 0x0f) | uint8((5&0xf)<<4) u[8] = (u[8] & 0x3f) | 0x80 // RFC 4122 variant