neo
neo copied to clipboard
Base58 perfomance patch
Description
Various Base58 performance improvements:
Decode():
- Replaced slow
IndexOf()to Base58 character map - Replaced
.TakeWhile(...).Count()to efficient variant, without memory and cpu-time loss - Replaced
byte[] Concat()to singleSpan<byte> - Fixed: zeros byte array creation only if decoded is zero
Type of change
- [x] Bug fix (non-breaking change)
How Has This Been Tested?
- [x] UT_Base58.TestEncodeDecode
- [x] UT_StdLib.TestBinary
Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas - no hard-to-understand areas
- [ ] I have made corresponding changes to the documentation - public API do not changed
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works - benchmarks only
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules - no dependent changes
P.S. It is my first time opening a pull request, please correct me if I've done something wrong.
@kzorin52 thank you very much for contributing to neo. This pr looks good to me.
@cschuchardt88 @shargon @AnnaShaleva @vncoelho
@shargon all fixed 🥳
@cschuchardt88 Okay, I'll do benchmarks and profiling of the code
I'm sorry, I've been really busy lately. As soon as I have free time, I will be able to make the planned benchmarks.