Skip to content

perf: remove vec in paint_order.rs - #69

Merged
LaurenzV merged 7 commits into
linebender:mainfrom
Its-Just-Nans:remove-vec
Oct 30, 2026
Merged

LaurenzV merged 7 commits into
linebender:mainfrom
Its-Just-Nans:remove-vec

Conversation

@Its-Just-Nans

@Its-Just-Nans Its-Just-Nans commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Little perf improvement by removing two vector creation

Note that the

// line 76-78
else {
    order = Self::default().order;
}

is for two special case.

If we remove it, we get:

---- paint_order::tests::parse_11 stdout ----
assert_eq!(PaintOrder::from_str("stroke stroke stroke stroke").unwrap(), PaintOrder::default());
  left: PaintOrder { order: [Stroke, Fill, Markers] } // The PR without the else
 right: PaintOrder { order: [Fill, Stroke, Markers] } // The wanted result


---- paint_order::tests::parse_5 stdout ----
assert_eq!(PaintOrder::from_str("stroke stroke").unwrap(), PaintOrder::default());
  left: PaintOrder { order: [Stroke, Fill, Markers] } // The PR without the else
 right: PaintOrder { order: [Fill, Stroke, Markers] } // The wanted result

Is this to conform to the specs or a deliberate choice ?

@Its-Just-Nans
Its-Just-Nans marked this pull request as draft October 21, 2026 20:00
@Its-Just-Nans
Its-Just-Nans marked this pull request as ready for review October 21, 2026 20:08
@Its-Just-Nans
Its-Just-Nans marked this pull request as draft October 21, 2026 20:21
@Its-Just-Nans
Its-Just-Nans marked this pull request as ready for review October 21, 2026 20:27

@LaurenzV LaurenzV left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the issue is addressed.

Comment thread src/paint_order.rs Resolved
@LaurenzV

Copy link
Copy Markdown
Collaborator

Is this to conform to the specs or a deliberate choice ?

I think this is intentional, because they are invalid, we should fall back to the default. But I'm not an expert either. 😓

@Its-Just-Nans

Its-Just-Nans commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Specification is here https://www.w3.org/TR/SVG2/painting.html#PaintOrder

When any of the other keywords are used, the order of the paint operations for painting the element is as given, from left to right.
If any of the three keywords are omitted, they are painted last, in the order they would be painted with paint-order: normal.

I fixed the test

@LaurenzV
LaurenzV enabled auto-merge October 30, 2026 22:24
@LaurenzV
LaurenzV added this pull request to the merge queue Oct 30, 2026
Merged via the queue into linebender:main with commit e7134d2 Oct 30, 2026
15 checks passed
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.

2 participants