perf: change ripmd160 from class to struct to avoid allocations. #121
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.
Main change: Ripemd160 hash calculator can be a struct as it is used only in one place and its instance is essentially ephemeral. No need to allocate it on heap.
Benchmark results:
Benchmark code:
I used 10k keys, because we have use cases where we need to prepare thousands of keys in single request, so I just lazily took benchmarks I already had. Single key benchmark should show similar levels of improvement in allocations (a byte saved is a byte earned).
Key2 -> is copy of existing Key class, but uses the struct ValueRipemd160 instead of the class one to calculate the digest.
Secondary changes: I'm working on Mac using Rider, I noticed that such a setup is not readily supported by this project. I made some changes to make life easier for non windows developers. Namely added Rider related stuff to .gitignore and added build configs which do not build Windows specific projects.
I added all changes into single PR, because it felt like it will be quicker.