-
Notifications
You must be signed in to change notification settings - Fork 3k
base64: allow skipping padding = characters #6711
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
Conversation
CT Test Results 2 files 88 suites 37m 45s ⏱️ Results for commit 3608e88. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
9ed22b5
to
a875385
Compare
Can you clarify this? Is it compatible with OTP 25 and previous releases or not? |
It is fully compatible with OTP 25 - there only the /1 functions exists and their behaviour didn't change. However, it is not compatible with current master which has the new /2 functions, but this new interface was never released |
Have you done any benchmarking to make sure that there is no a significant slowdown because of the new options? |
Here is a benchmark I have been using to test https://gist.github.com/bjorng/522470f313ac01d16156a597657f97bb It is based on the benchmark in #5639. |
Quick test on my machine shows no regression at all, at least for small strings. Here is before this PR:
And this is after, using new option:
I also tried with random 1Mb input, with the same effect. I wonder which case is expected to give the worst performance, when padding isn't needed, or when it needs 3 |
I couldn't measure any significant peformance difference on my mac. Before:
After:
@max-au the amount of padding shouldn't impact performance almost at all - it's basically linear in the length of the string. Since there's no copying or anything like that, it's just traversing or not the extra couple padding bytes (depending if they exist or not) - it shouldn't be noticeable. |
Thanks for benchmarking, @max-au and @michalmuskala. The OTP Technical Board will have to approve any API changes. To be able to approve the API, the board members will need to see a description of the API (not by reading the code). I have looked at your code and based on that look it seems to me that the API is reasonable and I find it likely that it will be approved. You can either write the documentation now or write a short API description in a comment in this PR. |
c0cb93d
to
0ba36bb
Compare
I pushed a commit updating documentation |
0ba36bb
to
3608e88
Compare
I have pushed two fixup commits. The first is addition of links (suggested by @RaimoNiskanen); the other is an updated description of the default value that I find less confusing. If you agree, please squash the commits. When you are done, I'll merge the PR. |
This extends base64 encoding and decoding routines to allow skipping emitting final = characters, or to accept encoded data with final = characters skipped. This format is common for some use-cases. Today, parsing it requires appending the missing = characters, which incurs an unnecessary copy of the input data, or re-implementing the entire routine. This amends the interface in a backwards-incompatible way, since the last change wasn't released yet, so should have no expectation of backwards-compatibility. Additionally, tests are slightly enhanced to cover more cases directly with simple examples.
d6dc97a
to
4f33e44
Compare
Rebased on fresh master & squashed commits |
This extends base64 encoding and decoding routines to allow skipping emitting final = characters, or to accept encoded data with final = characters skipped. This format is common for some use-cases. Today, parsing it requires appending the missing = characters, which incurs an unnecessary copy of the input data, or re-implementing the entire routine.
This amends the interface in a backwards-incompatible way, since the last change wasn't released yet, so should have no expectation of backwards-compatibility.
Additionally, tests are slightly enhanced to cover more cases directly with simple examples.
If this change is accepted, I will provide documentation.