Skip to content

Commit 21dbdbe

Browse files
committed
alloc
1 parent 2b42965 commit 21dbdbe

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

bevy_quadtree/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Features:
7676

7777
### Caution
7878

79-
- For those who upgrade from version <= 0.15.1-alpha7, pay attention to the new type paramter `D` in `QuadTreePlugin`.
79+
For those who upgrade from version <= 0.15.1-alpha7, pay attention to the new type paramter `D` in `QuadTreePlugin`.
8080
And shapes now have `ID` as well. Moreover, the tree memory is pre-allocated, no longer dynamically allocating.
8181

8282
<p align="right">(<a href="#readme-top">back to top</a>)</p>

bevy_quadtree/src/tree/tree_impl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use bevy_math::{Rect, Vec2};
1010
use core::fmt;
1111
use parking_lot::RwLock;
1212
use std::{
13-
alloc::{GlobalAlloc, Layout, System},
13+
alloc::{alloc, dealloc, Layout},
1414
any::type_name,
1515
ops::Index,
1616
sync::atomic::{AtomicBool, Ordering},
@@ -66,7 +66,7 @@ impl<const N: usize, const D: usize, const W: usize, const H: usize, const K: us
6666
fn drop(&mut self) {
6767
unsafe {
6868
let layout = Layout::array::<Node<K>>(Self::MAX_LEN).expect("`D` is too large");
69-
System.dealloc(self.nodes as *mut u8, layout);
69+
dealloc(self.nodes as *mut u8, layout);
7070
}
7171
}
7272
}
@@ -79,7 +79,7 @@ impl<const N: usize, const D: usize, const W: usize, const H: usize, const K: us
7979
pub(crate) fn new() -> Self {
8080
unsafe {
8181
let layout = Layout::array::<Node<K>>(Self::MAX_LEN).expect("`D` is too large");
82-
let nodes = System.alloc(layout) as *mut Node<K>;
82+
let nodes = alloc(layout) as *mut Node<K>;
8383
nodes.write(Node::root(Rect::from_center_size(
8484
Vec2::ZERO,
8585
Vec2::new(W as f32, H as f32),

0 commit comments

Comments
 (0)