Skip to content

Commit dd44be3

Browse files
committed
Optimize paths without markers
1 parent f4188dd commit dd44be3

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

crates/usvg/src/parser/converter.rs

+7-17
Original file line numberDiff line numberDiff line change
@@ -931,29 +931,19 @@ fn convert_path(
931931
None => return,
932932
};
933933

934-
match raw_paint_order.order {
935-
[PaintOrderKind::Markers, _, _] => {
936-
if let Some(markers_node) = marker {
937-
parent.children.push(Node::Group(Box::new(markers_node)));
938-
}
939-
934+
match (raw_paint_order.order, marker) {
935+
([PaintOrderKind::Markers, _, _], Some(markers_node)) => {
936+
parent.children.push(Node::Group(Box::new(markers_node)));
940937
parent.children.push(Node::Path(Box::new(path.clone())));
941938
}
942-
[first, PaintOrderKind::Markers, last] => {
939+
([first, PaintOrderKind::Markers, last], Some(markers_node)) => {
943940
append_single_paint_path(first, &path, parent);
944-
945-
if let Some(markers_node) = marker {
946-
parent.children.push(Node::Group(Box::new(markers_node)));
947-
}
948-
941+
parent.children.push(Node::Group(Box::new(markers_node)));
949942
append_single_paint_path(last, &path, parent);
950943
}
951-
[_, _, PaintOrderKind::Markers] => {
944+
([_, _, PaintOrderKind::Markers], Some(markers_node)) => {
952945
parent.children.push(Node::Path(Box::new(path.clone())));
953-
954-
if let Some(markers_node) = marker {
955-
parent.children.push(Node::Group(Box::new(markers_node)));
956-
}
946+
parent.children.push(Node::Group(Box::new(markers_node)));
957947
}
958948
_ => parent.children.push(Node::Path(Box::new(path.clone()))),
959949
}
Loading
Loading

crates/usvg/tests/write.rs

+5
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,8 @@ fn preserve_text_with_complex_text_decoration() {
203203
fn preserve_text_with_nested_baseline_shift() {
204204
resave_with_text("preserve-text-with-nested-baseline-shift");
205205
}
206+
207+
#[test]
208+
fn optimize_paths_without_markers() {
209+
resave("optimize-paths-without-markers");
210+
}

0 commit comments

Comments
 (0)