iancoleman / strcase

A golang package for converting to snake_case or CamelCase
MIT License
1.01k stars 106 forks source link

Better number handling and general performance #24

Closed NathanBaulch closed 4 years ago

NathanBaulch commented 4 years ago

Thanks for this handy package.

I discovered various issues with number handling (not including but related to #22) and along the way found lots of performance improvement opportunities. These include removing the numbers regexp, switching from string concatenation to strings.Builder and manually handling trim and to upper/lower operations.

By benchmarking the existing unit test suite I was able to measure speed improvements of 15x for snake/kebab and 20x for camel.

It was easier to send a single monolithic PR but happy to break it up if you prefer.

iancoleman commented 4 years ago

This is fantastic, thankyou!

NathanBaulch commented 4 years ago

No worries at all... Also, greetings from Melbourne 😁

iancoleman commented 4 years ago

Haha yep stage 4 lockdown life :fist_raised: :smile: stay well!