From 132e38e050f21994960239384a54b6a64b9b3a95 Mon Sep 17 00:00:00 2001 From: joe Date: Thu, 23 Oct 2025 11:11:59 -0700 Subject: [PATCH] use the bump allocator for radius, doesn't help much --- src/lib.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a619039..84b0d8d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 { 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.