Open NullVoxPopuli opened 8 years ago
You are probably in a better place to make a more performant camel case converter than I am :wink:
I’ve been watching conversations in https://github.com/whatisinternet/inflector/pull/26 and https://github.com/whatisinternet/inflector/issues/25 with @whatisinternet, and they’ve been awesome :blush:
The real reason I ended up writing my own inflector crate wasn’t so much because I wanted better performance (as that’s not my area of expertise), but rather because I wanted a better API (which is more my speed :wink:). For instance I wanted a clean import like use inflections::case::*;
. I also wanted a few other cases like Train-Case (as I was working with HTTP headers at the time). In addition, having a class case that also ran a singularize function was a deal breaker when I wanted a simple PascalCase conversion. Layer on top the fact I thought I could make something with baseline better performance I decided to go for it.
@whatisinternet is doing a great job, and I don’t have too many reasons at the moment to continue maintaining this or improving it. I’m totally willing, however, to make you a collaborator @NullVoxPopuli and/or give you the package name so you can deploy your own optimized code. It should be a super simple substitution, just replace the function body of to_camel_case
and everything should just work.
My hunch on performance is that the Iterator
methods I use (scan
and collect
) are why my implementation is less performant. In normal scenarios the overhead is really not that much, but in a camel case converter the overhead may be too much. However, when it comes to performance I think benchmarks are way more important than theory.
Thanks for the kind words @calebmer . ☺
In terms of the code from Reddit it very closely mirrors my code from infector. Namely https://github.com/whatisinternet/inflector/blob/master/src/cases/camelcase/mod.rs#L70.
@calebmer if you're interested in helping out on infector I can grant commit access if you feel like making a more ergonomic API.
https://www.reddit.com/r/rust/comments/554skr/how_do_i_set_up_memoization_for_a_function/d88soy2
I'm still new to rust, so I'm not really sure what the advantages/disadvantages are of certain approaches (such as your scan functions)