Use much faster JDK utility for converting an int to a byte sequence. #163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At the moment Lettuce uses a private helper method accepting a long parameter to write the length of a String or byte array to redis.
First off, this length will be always "int",
secondly, the method uses a hand written StringBuilder and number % 10 algorithm to translate the long into a string.
It will produce a String 4321 for a length of 1234. This string will be reversed and the char values appended to the buffer.
The JDK however comes with the handy util Integer.toString(intValue) which will produce a correctly ordered String. This method is much faster and also benefits from improvements done to the JDK
(this was actually done quite recently: http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-November/036765.html)
In summary this improves CPU and memory usage of this method.