Fix reflist diffs failing to compact when one of the inputs ends #1275
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.
Replaces #1233
Requirements
All new code should be covered with tests, documentation should be updated. CI should pass.
Description of the Change
The previous reflist logic would early-exit the loop body if one of the lists was empty, but that skips the compacting logic entirely.
Instead of doing the early-exit, we can leave a list's ref as nil when the list end is reached and then flip the comparison result, which will essentially treat it as being greater than all others. This should preserve the general behavior without omitting the compaction.
I suspect this might fix #282 and/or #287, but I haven't tested that.
An alternate approach in the same vein is to create a "sentinel" slice like:
and then use that when we reach the end of a reflist, which avoids the need to flip the comparison result. However, the code later on that checks if the ref is set would then look like:
which felt worse to me while also being a tad wasteful (extra slice allocation every call!). That being said, omitting the comparison flip could certainly be seen as cleaner.
Checklist
AUTHORS