This is an alternative to #5 (Cc: @Code-Hex).
A bit slower than #5, but much less memory used. Still significantly faster than the original NewGraphemes.
The second commit is the benchmark. Just cherry-pick the first commit if you don't want the benchmark.
$ go test -benchmem -bench B
goos: darwin
goarch: amd64
pkg: github.com/rivo/uniseg
BenchmarkCountOriginal-4 2991 387297 ns/op 96392 B/op 3458 allocs/op
BenchmarkCountCodeHex-4 4665 274718 ns/op 105544 B/op 1865 allocs/op
BenchmarkCountDolmen-4 4227 291797 ns/op 77776 B/op 1865 allocs/op
This is an alternative to #5 (Cc: @Code-Hex). A bit slower than #5, but much less memory used. Still significantly faster than the original
NewGraphemes
.The second commit is the benchmark. Just cherry-pick the first commit if you don't want the benchmark.