Closed charlievieth closed 1 year ago
Do you have an actual use case in your application where you work with slices of runes?
@charlievieth the way to avoid the conversions is to re-write the code in this package to not use []rune internally. Doing so speeds up common operations and only has slight slowdowns for less common operations.
I can only guess you're suggesting this API because you have some code with []rune
already; a lot of the Go code I see using []rune
shouldn't be so I'd also suggest reviewing said code and making sure it really benefits from []rune
(often for an extremely minor increase in code complexity []rune
conversions can be removed entirely and the resulting code runs faster by avoiding conversions; especially as the input size increases).
I believe this PR also doesn't apply anymore after the rewrite last year.
Add NewGraphemesFromRunes which allows for creating a new Graphemes struct from a slice of runes (saving the []rune => str => []rune conversion).