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

Small optimizations for the base64 decoder #1278

Merged
merged 5 commits into from
Apr 24, 2023
Merged

Conversation

ahrav
Copy link
Collaborator

@ahrav ahrav commented Apr 22, 2023

Additional optimizations to the base64 decoder.:

  • Remove the bytes.Contains and replace with a constant time lookup using a b64 charset mapping using a fixed array.
  • Instead of using a bytes.Buffer to store the characters of a substring, track the start and end positions of a substring in data during getSubstringsOfCharacterSet.
  • Handle chunk Data replacement in a single pass.

Screenshot 2023-04-22 at 1 14 19 PM

Screenshot 2023-04-22 at 1 14 31 PM

Screenshot 2023-04-22 at 12 57 18 PM

@ahrav ahrav changed the title Small optimizations. Small optimizations for the base64 decoder Apr 22, 2023
@ahrav ahrav force-pushed the baes64-decoder-optimizations branch from 3c0dadf to 4ec17fb Compare April 22, 2023 20:44
@ahrav ahrav marked this pull request as ready for review April 22, 2023 21:42
@ahrav ahrav requested a review from a team as a code owner April 22, 2023 21:42
Copy link
Contributor

@dustin-decker dustin-decker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! One comment on a potential improvement.

@ahrav ahrav merged commit 34f5db6 into main Apr 24, 2023
7 checks passed
@ahrav ahrav deleted the baes64-decoder-optimizations branch April 24, 2023 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants