Skip to content

Optimize Base58 encoding/decoding #21

@aslesarenko

Description

@aslesarenko

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions