Skip to content

Commit

Permalink
optimize maxBytes calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
anatoly-kussul committed Jan 6, 2025
1 parent c958a3c commit 43645fa
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions alphabet.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ func newAlphabet(s string) alphabet {
chars: abc,
len: int64(len(abc)),
encLen: uint8(math.Ceil(128 / math.Log2(float64(len(abc))))),
maxBytes: 1,
}
for _, c := range a.chars {
a.maxBytes = max(a.maxBytes, uint8(utf8.RuneLen(c)))
maxBytes: uint8(utf8.RuneLen(abc[len(abc)-1])),
}

return a
Expand Down

0 comments on commit 43645fa

Please sign in to comment.