Chore: BufferTransformer and Blowfish Refactor #4151
Draft
+513
−78
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This picks up the work started in #3942 by proposing a
BufferTransformer
class; which is essentially an orchestrator forBufferSlicer
andBufferStuffer
. As mentioned yesterday, I added some template fanciness, to handle the "block processing" necessary for various block ciphers. As suggested previously, this uses Blowfish to demonstrate the functionality (+ spanifying the blowfish implementation).@randombit Is the
process_blocks_of<>
implementation in line with what you had in mind previously:Here's the idea of
BufferTransformer::process_blocks_of
, where the multi-block loop handling and buffer management is entirely abstracted. Also, as an additional goodie, we now have explicit compile-time knowledge of the blocked data length inside the processing lambdas. Whether the compiler uses this or not has to be seen. FWIW: I don't see a difference in the performance of Blowfish on my Mac.No hard feelings if that doesn't make it into 3.5.0 at all. I just nerd-sniped myself yesterday and wanted to sketch this out. And frankly, I think the
BufferTransformer
implementation is quite concise. 😄