Block splitter : minor reformatting #3376
Merged
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.
After reading #3204, I wanted to have a look at the block splitter to understand what's going on.
This exercise lead to a (rather large) number of minor changes, which initially were cosmetic only, but eventually added a few correctness updates. They don't change the behavior of the functionality, but hopefully improve maintenance.
List of changes:
offset
tooffbase
was done manually, instead of employing the dedicated macrosconst
correctness :seqStore
was passed as a mutable buffer in scenarios where it was read only. The pb ran multiple levels deep, so several functions where controlled and their prototype updated to reflect this property.const
, improving the understanding of what happens to them. Some variables could be removed, others could be moved to a more restrictive scope-Wconversion
warning level (note: not activated by default onzstd
code base)assert()
were added, to better document what's the expected state of the system.Only minor stuff, but I figure it was still valuable enough for maintenance to be merged.
None of these changes impact the behavior of the program. The source code is stricter, but it still does the same thing.
A side effect of this exercise is that I have a better understanding of the block splitter now.
The estimation logic, which judges if a splitting decision is beneficial or not, looks fine and seems generally re-usable.
The splitting decision though is still pretty raw, blindly mechanical.
Hence, that's where improvements could be inserted.
That being said, adding complexity at this stage is also likely going to impact speed.
So it might become desirable to feature multiple "levels" of block splitting.