sqids / sqids-go

Official Go port of Sqids. Generate short unique IDs from numbers.
https://sqids.org/go
MIT License
492 stars 8 forks source link

Use `[]rune` instead of `string` in `Encode`/`Decode` #20

Closed peterhellberg closed 10 months ago

peterhellberg commented 10 months ago

Note With this change it would be possible to support multibyte characters in alphabets if it was allowed by the spec.

Benchmark

$ time go test -bench=. -run=BenchmarkEncodeDecode -benchmem -cpuprofile profile.out
goos: linux
goarch: amd64
pkg: github.com/sqids/sqids-go
cpu: Intel(R) Core(TM) i7-10700T CPU @ 2.00GHz
BenchmarkEncodeDecode-16           30134         38607 ns/op       16648 B/op        132 allocs/op
PASS
ok      github.com/sqids/sqids-go   1.711s

real    0m1.929s
user    0m1.971s
sys 0m0.183s