Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented a few improvements #96

Open
sblinch opened this issue Apr 12, 2024 · 0 comments
Open

Implemented a few improvements #96

sblinch opened this issue Apr 12, 2024 · 0 comments

Comments

@sblinch
Copy link

sblinch commented Apr 12, 2024

I've implemented a few improvements to gotext for my own use and thought I'd offer them back.

The first is a set of "Append" equivalents to the Get[NC] methods that append to a byte slice instead of allocating new strings. This improves performance substantially:

BenchmarkGoText/strings-16                748399              1627 ns/op             160 B/op          6 allocs/op
BenchmarkGoText/byte-slices-16           1044115              1094 ns/op              48 B/op          3 allocs/op

I also have a patch that replaces gotext's maps/mutexes with lock-free hashmaps. The performance improvement wasn't as dramatic as I had hoped, and it requires an additional dependency (hashmap) and bumping the required Go version to 1.18 for generics support, so I'm not sure it'll meet the bar for inclusion in gotext. Performance (vs the above):

BenchmarkGoTextHashmaps/strings-16          915142              1342 ns/op             160 B/op          6 allocs/op
BenchmarkGoTextHashmaps/byte-slices-16     1195036               893.6 ns/op            48 B/op          3 allocs/op

If there's any interest, I can rebase it on top of the current version and push it to my repo for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant