use the bump allocator for radius, doesn't help much

This commit is contained in:
joe 2025-10-23 11:11:59 -07:00
parent d28d212821
commit 132e38e050

View file

@ -1,3 +1,5 @@
#![feature(allocator_api)]
use std::{
collections::HashMap,
sync::{Mutex, RwLock},
@ -156,10 +158,21 @@ impl Spindex2d {
/// Search within a given `radius` from `point`.
pub fn radius(&self, point: &Point2d, radius: f64) -> Vec<Point2d> {
let d2 = radius.powi(2);
self.aabb(point, radius * 2.0)
.into_iter()
.filter(|v| v.distance_squared(point) <= d2)
.collect()
let points = self.aabb(point, radius * 2.0);
let mut alloc = self.alloc.lock().unwrap();
let neighbors = {
let mut neighbors = Vec::new_in(alloc.local());
for neighbor in points.into_iter() {
if neighbor.distance_squared(point) <= d2 {
neighbors.push(neighbor);
}
}
neighbors.to_vec()
};
alloc.reset();
neighbors
}
/// Search an axis-aligned bounding box whose sides are `span` away from the given point.