uniseg icon indicating copy to clipboard operation
uniseg copied to clipboard

Add ResetString

Open klauspost opened this issue 3 years ago • 3 comments

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

klauspost avatar Aug 25 '21 13:08 klauspost

FYI, if #11 and #10 get completed then the Graphemes struct won't do any allocation and this wouldn't be needed.

dchapes avatar Aug 27 '21 10:08 dchapes

@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 avatar Aug 27 '21 15:08 rivo

@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.

klauspost avatar Aug 30 '21 14:08 klauspost

I think given the package rewrite from last year, this PR is not relevant anymore.

rivo avatar Jul 22 '23 10:07 rivo