Skip to content

Commit

Permalink
Preallocate vecs
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncozens committed Jun 6, 2024
1 parent 0024c8a commit f9d5eec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions triangulate/src/glyph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub(crate) fn interpolate_glyph(
}

fn get_contour_numbers(g: &Glyph) -> ndarray::Array1<f64> {
let mut v = vec![];
let mut v = Vec::with_capacity(2 * g.contours.iter().map(|c| c.points.len()).sum::<usize>());
for contour in g.contours.iter() {
for p in &contour.points {
v.push(p.x);
Expand Down Expand Up @@ -80,7 +80,7 @@ fn set_anchor_numbers(g: &mut Glyph, values: &[f64]) {
}

fn get_component_numbers(g: &Glyph) -> ndarray::Array1<f64> {
let mut v = vec![];
let mut v = Vec::with_capacity(6 * g.components.len());
for component in g.components.iter() {
v.push(component.transform.x_scale);
v.push(component.transform.xy_scale);
Expand Down

0 comments on commit f9d5eec

Please sign in to comment.