mirror of
https://github.com/penpot/penpot.git
synced 2025-07-13 02:47:16 +02:00
♻️ Refactor surface iteration
This commit is contained in:
parent
8922e7454f
commit
fcd3e5c34c
6 changed files with 95 additions and 113 deletions
|
@ -52,9 +52,7 @@ impl ShapesPool {
|
|||
}
|
||||
|
||||
self.shapes.extend(
|
||||
iter::repeat_with(
|
||||
|| Box::new(Shape::new(Uuid::nil()))
|
||||
).take(additional as usize)
|
||||
iter::repeat_with(|| Box::new(Shape::new(Uuid::nil()))).take(additional as usize),
|
||||
);
|
||||
performance::end_measure!("shapes_pool_initialize");
|
||||
}
|
||||
|
@ -62,11 +60,8 @@ impl ShapesPool {
|
|||
pub fn add_shape(&mut self, id: Uuid) -> &mut Shape {
|
||||
if self.counter >= self.shapes.len() {
|
||||
let additional = (self.shapes.len() as f32 * SHAPES_POOL_ALLOC_MULTIPLIER) as usize;
|
||||
self.shapes.extend(
|
||||
iter::repeat_with(
|
||||
|| Box::new(Shape::new(Uuid::nil()))
|
||||
).take(additional)
|
||||
);
|
||||
self.shapes
|
||||
.extend(iter::repeat_with(|| Box::new(Shape::new(Uuid::nil()))).take(additional));
|
||||
}
|
||||
let new_shape = &mut self.shapes[self.counter];
|
||||
new_shape.id = id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue