Skip to content

Simplify tiered lines elider#302

Merged
jas14 merged 4 commits intomainfrom
simplify-tiered-lines-elider
Feb 14, 2026
Merged

Simplify tiered lines elider#302
jas14 merged 4 commits intomainfrom
simplify-tiered-lines-elider

Conversation

@jas14
Copy link
Collaborator

@jas14 jas14 commented Feb 13, 2026

While reviewing #300, I noticed some unrelated clean-up opportunities in TieredLinesElider.

Most importantly, Pane#padded was essentially a no-op. This PR gets rid of it, and simplifies up the call stack through TieredLinesElider#panes.

Less importantly, and more for my own satisfaction, #filter_out_boxes_fully_contained_in_others was $O(n^2)$; assuming sorting is sub-quadratic, it's also now sub-quadratic.

At some point in the development of diff elision, it looks like dirty
panes might have been padded to preserve context. However, the
implementation that was eventually introduced in d18bd14
ended up essentially cloning the original pane with no padding. This
makes #padded, and subsequently #capped_to, unnecessary.
By construction, `dirty_panes` never returns contiguous dirty panes.
Since the panes were never really padded, those panes remained untouched
until passed into `#combine_congruent_panes`, so that method was
essentially a no-op. Removing that method subsequently obviated the need
for `#padded_dirty_panes` entirely.
`sorted_boxes` was first sorted, then used in an `#any?` check. In worst-case
time complexity, this is just as (in)efficient as checking against the
unsorted boxes.

We can do better by sorting boxes by beginning ascending and ending
descending. Algorithm explanation in comments.
@jas14 jas14 marked this pull request as ready for review February 13, 2026 22:44
@jas14 jas14 merged commit 060d503 into main Feb 14, 2026
72 checks passed
@jas14 jas14 deleted the simplify-tiered-lines-elider branch February 14, 2026 00:16
jas14 added a commit to gschlager/super_diff that referenced this pull request Feb 14, 2026
While reviewing splitwise#300, I noticed some unrelated clean-up opportunities in
`TieredLinesElider`.

Most importantly, `Pane#padded` was essentially a no-op. This PR gets
rid of it, and simplifies up the call stack through
`TieredLinesElider#panes`.

Less importantly, and more for my own satisfaction,
`#filter_out_boxes_fully_contained_in_others` was $O(n^2)$; assuming
sorting is sub-quadratic, it's also now sub-quadratic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant