Skip to content

Commit 4a9b48f

Browse files
committed
performance fix
1 parent 036d21e commit 4a9b48f

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

iOverlay/src/core/divide.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl ContourDecomposition for IntContour {
4545
.map(|(i, &p)| IdPoint::new(i, p))
4646
.collect();
4747

48-
id_points.sort_by(|p0, p1| p0.point.cmp(&p1.point).then_with(|| p0.id.cmp(&p1.id)));
48+
id_points.sort_unstable_by(|p0, p1| p0.point.cmp(&p1.point).then_with(|| p0.id.cmp(&p1.id)));
4949

5050
let mut p0 = id_points.first().unwrap().point;
5151
let mut anchors = Vec::new();

iOverlay/src/core/extract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl OverlayGraph<'_> {
170170
}
171171

172172
if !anchors_already_sorted {
173-
anchors.sort_by(|s0, s1| s0.v_segment.a.cmp(&s1.v_segment.a));
173+
anchors.sort_unstable_by(|s0, s1| s0.v_segment.a.cmp(&s1.v_segment.a));
174174
}
175175

176176
shapes.join_sorted_holes(holes, anchors, clockwise);

iOverlay/src/core/extract_ogc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl OverlayGraph<'_> {
168168
}
169169

170170
if !anchors_already_sorted {
171-
anchors.sort_by(|s0, s1| s0.v_segment.a.cmp(&s1.v_segment.a));
171+
anchors.sort_unstable_by(|s0, s1| s0.v_segment.a.cmp(&s1.v_segment.a));
172172
}
173173

174174
shapes.join_sorted_holes(holes, anchors, is_main_dir_cw);

iOverlay/src/split/solver_fragment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ impl SplitSolver {
108108
marks: Vec<LineMark>,
109109
}
110110

111-
let marks_capacity = self.marks.len() / buffer.groups.len();
111+
debug_assert!(!buffer.groups.is_empty(), "groups.len() >= 1");
112+
let marks_capacity = self.marks.capacity() / buffer.groups.len();
112113

113114
let results: Vec<TaskResult> = buffer
114115
.groups

0 commit comments

Comments
 (0)