Open
Conversation
The logging is almost useless for users but a developer can debug in IDE. The raw keys bytes are not saying anything. We have errors to return a message to a caller. In the same time the code needs to be compiled and it makes the program slower because it resides in CPU cache.
Remove deprecated isDebugMode
These fields are never read but consumes memory. If we are going to create many instances of the Pricer then it will consume a lot of memory and make program slower
The function will decode the string key
You can decode the keys one and then create multiple pricers with them.
It will never occur. Even seed is just an empty string the md5 hash will be not empty
The method accepts a price in raw bytes. It also receives a buffer for decoding which can be reused later
It can be pre-allocated. This saved one allocation and improved speed
The generated assembly has a cycle to make xor with two arrays p and pad. Given that the two arrays have only 8 bytes we can convert them to uint64 and perform a usual xor. The optimization makes code harder to read and saves only about 4ns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I going to reuse a pricer instances and put them to a sync.Pool
In the same time I receiving the encryptedPrice as []byte so on conversion to string it creates an allocation.
Here I extracted a separate method DecodeRaw() that can work directly with []byte.
But also it can reuse a buffer and count of allocations significantly reduced.
Under a heavy load this is a very good thing