🎉 Improve performance reducing unnecessary calls to set-objects

This commit is contained in:
Alejandro Alonso 2025-03-25 16:21:03 +01:00
parent e012046f62
commit 7728d5b317
20 changed files with 360 additions and 180 deletions

View file

@ -1,9 +1,8 @@
use skia_safe as skia;
use std::collections::{HashMap, HashSet};
use uuid::Uuid;
use crate::uuid::Uuid;
use crate::view::Viewbox;
use indexmap::IndexSet;
use skia_safe as skia;
use std::collections::{HashMap, HashSet};
pub type Tile = (i32, i32);
@ -64,6 +63,12 @@ impl TileHashMap {
return self.grid.get(&tile);
}
pub fn remove_shape_at(&mut self, tile: Tile, id: Uuid) {
if let Some(shapes) = self.grid.get_mut(&tile) {
shapes.shift_remove(&id);
}
}
pub fn get_tiles_of(&mut self, shape_id: Uuid) -> Option<&HashSet<Tile>> {
self.index.get(&shape_id)
}