hashids-java
hashids-java copied to clipboard
performance improvements
Could you fix formatting, otherwise it's impossible to analyze the diff with so many changes. Thanks.
Also, if you could explain the performance improvements would help.
I have fixed the formatting.
The performance consists in:
- using operations directly to the char arrays instead of using
String
; - some operations (like computing the
validChars
,guardsRegExp
,sepsRegExp
, regexp pattern) are precomputed and cached; - usage of StringBuilder instead of operating with strings (see
StringBuilder buffer
,ret_strB
,StringBuilder hash
, etc.); - adding a helper class (
CharUtils
) for working with char arrays.
About the performance: I have gained about 100-200 ms for running all the tests (it is at least 20% more efficient).
Great, I'll take some time to review and get back to you. Thanks.
About breaking this pull request in smaller pieces: I can't do this because the most part of it is related to the migration from String
to char[]
. I may extract the constants and the validation method but it will not help much reviewing the code (because those changes are only a couple of lines).
@cazacugmihai what do you think about creating a branch and work on a new version? @gabrielhora you are invited to this discussion. I'll create an issue to work on that.
Sure, I can do that.
Issue 55 - V2 Proposal. Let's discuss there before starting to code.