uniseg
uniseg copied to clipboard
Add ResetString
Add ResetString that allows to reuse the Grapheme without allocating internals.
Copied a simple benchmark to verify it:
cpu: AMD Ryzen 9 3950X 16-Core Processor
BenchmarkCountDolmen-32 7058 164430 ns/op 75297 B/op 1865 allocs/op
BenchmarkCountDolmenResetString-32 12128 98766 ns/op 96 B/op 1 allocs/op
PASS
FYI, if #11 and #10 get completed then the Graphemes
struct won't do any allocation and this wouldn't be needed.
@dchapes I was wondering if I had missed something but looking into #10 and #11, I see that I'm currently waiting for your input. For #10, no PR has been submitted yet. And regarding #11, there were some minor requests which hadn't been resolved yet.
It sounds like the #10 PR will functionally overlap with this PR, so I hope whatever the decision will be, there won't be any hurt feelings on either side.
@rivo Do what you want. This was a simple change to get 95% of the way, without breaking anything.
A byte API for fully allocation-less operation would be nice, but it beyond what I can commit to.
I think given the package rewrite from last year, this PR is not relevant anymore.