Replace legacy Base64 implementation with libbase64 - #116
Conversation
| int outcount = b64pipe.Put(buffer, length); | ||
| total += outcount; | ||
| int filtered_count = 0; | ||
| for (int offset = 0; offset < length; offset++) { |
There was a problem hiding this comment.
What is all this, why is it needed?
The input should already be base64, I dont think the original implementation deviated?
There was a problem hiding this comment.
The original decoder was different here: Base64_Decode explicitly ignored every character outside the Base64 alphabet and stopped at the first "=" character. Get_UUBlock reached it via Base64Pipe, so the existing permissive decoding behavior for old INI data is preserved.
I agree that this is more code than is required for the normal path.
filtering exists only for compatibility with the old decoder.
If we do not consider support for damaged/non-standard UUBlocks important, then the code in this place can be greatly simplified
There was a problem hiding this comment.
I think this should be moved to its own function that just validates the input and returns a log error if its invalid.
I don't see a logical reason to try to work around a bad input, bad input is bad input, the user needs to fix it.
|
Is there a benchmark driven reason for this? |
|
Can we keep the pipe/straw classes? They're idiomatic here. Replace the actual base64 impl instead? |
UUBlock encoding and decoding are not per-frame hot paths, so I do not think a benchmark is necessary. libbase64 should still be significantly faster for large blocks, and I can measure that if useful. The primary motivation was maintenance: the bespoke codec plus Base64Pipe and Base64Straw were only used for UUBlock handling. libbase64 replaces that isolated implementation with a tested library while preserving the stored format |
We can, but these are not general-purpose adapters in the current tree: Base64Pipe and Base64Straw are only used by the two UUBlock functions. They also buffer a single Base64 quantum ( Keeping them is reasonable if preserving the local Pipe/Straw shape is more important than removing the unused abstraction. Otherwise, I think calling the library directly is the simpler result. |
Would it not be possible to rework the pipes to solve the buffering? |
Keep the existing UUBlock INI format while enabling SIMD-accelerated encoding and decoding
e99bf3c to
1d97c20
Compare
We can rework the adapters around libbase64’s streaming API, but I do not think they are needed here. |
|
Development builds of 1d97c20: The links work without a GitHub account. Artifacts expire after 90 days, and this comment follows the latest successful build. |
Krisztiaan
left a comment
There was a problem hiding this comment.
#113 overlaps with this btw
| int copy_count = std::min(len - total, static_cast<int>(decoded_count)); | ||
| std::memcpy(static_cast<char *>(block) + total, decoded, copy_count); | ||
| total += copy_count; | ||
| if (finished || total == len) { |
There was a problem hiding this comment.
This stops the entire section at the first padding marker. Base64Pipe decoded each four-character group independently and continued into later entries, entries containing TQ== followed by TWFu change from MMan to M. Preserve that accepted input unless we want to break compat.
The custom Base64 codec is legacy code used only for INI UUBlock serialization.
This replaces it with SIMD-accelerated libbase64 while keeping the existing UUBlock format compatible.
The UUBlock coverage is part of the existing
IniContracttest, not a separate test target.