Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Base58 encoding/decoding #21

Open
aslesarenko opened this issue May 26, 2020 · 1 comment
Open

Optimize Base58 encoding/decoding #21

aslesarenko opened this issue May 26, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@aslesarenko
Copy link
Collaborator

aslesarenko commented May 26, 2020

Can only be done after #27

Problem

Existing implementation of scorex.util.encode.Base58 is a potential performance bomb, especially encoding, which copy the whole string buffer for each new character (which is added at the beginning of the buffer). It essentially make the algorithm O(n^2) where n is the length of the resulting string.

Solution

  • avoid using foldLeft and functional abstractions.
  • put characters in ArrayBuilder[Char] and then move them to StringBuilder in reverse order.
@aslesarenko aslesarenko added the enhancement New feature or request label May 26, 2020
@pragmaxim
Copy link

Screenshot from 2023-06-16 10-51-14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants