Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@ChristopherWirt
Copy link

When profiling I noticed a large number of strings being generated from AbstractBase64UrlEncoder.decode(). I think this is mostly attributable to the string concatenation inside the various loops. To fix this I've switched to using a StringBuilder. This avoids new strings being allocated on each iteration.

I've also removed the use of regular expressions to validate inputs these are also relatively expensive to be happening at such a low level of the code. For bitString validation I've used a simple char inspecting method. For base64 I just used the absence of it appearing in the REVERSE_DICT to indicate this is an invalid base64 string.

Finally to reduce auto-boxing I switched to using a Char2IntOpenHashMap for holding the REVERSE_DICT. To do this I've had to import a 3rd party fast utils lib - which is a lightweight collection of optimised primitive collection types, useful in cases like this.

When profiling I noticed a large number of strings being generated from
AbstractBase64UrlEncoder.decode(). I think this is mostly attributable
to the string concatenation inside the various loops. To fix this I've
switched to using a StringBuilder. This avoids new strings being
allocated on each iteration.

I've also removed the use of regular expressions to validate inputs
these are also relatively expensive to be happening at such a low level
of the code. For bitString validation I've used a simple char inspecting
method. For base64 I just used the absence of it appearing in the
REVERSE_DICT to indicate this is an invalid base64 string.

Finally to reduce autoboxing I switched to using a Char2IntOpenHashMap
for holding the REVERSE_DICT. To do this I've had to import a 3rd party
fast utils lib.
@yuzawa-san
Copy link
Contributor

I expanded upon the ideas in this pr in my own pr #56 please take a look

@ChristopherWirt
Copy link
Author

closing in favor of #56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.