mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 04:33:06 +00:00
remove bump in generational box
This commit is contained in:
parent
88e2da6c11
commit
65c0d213e3
2 changed files with 2 additions and 7 deletions
|
@ -10,7 +10,6 @@ keywords = ["generational", "box", "memory", "allocator"]
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
bumpalo = { version = "3.6" }
|
||||
|
||||
[dev-dependencies]
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -11,8 +11,6 @@ use std::{
|
|||
rc::Rc,
|
||||
};
|
||||
|
||||
use bumpalo::Bump;
|
||||
|
||||
/// # Example
|
||||
///
|
||||
/// ```compile_fail
|
||||
|
@ -615,14 +613,12 @@ impl Drop for GenerationalRefMutBorrowInfo {
|
|||
/// Handles recycling generational boxes that have been dropped. Your application should have one store or one store per thread.
|
||||
#[derive(Clone)]
|
||||
pub struct Store {
|
||||
bump: &'static Bump,
|
||||
recycled: Rc<RefCell<Vec<MemoryLocation>>>,
|
||||
}
|
||||
|
||||
impl Default for Store {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
bump: Box::leak(Box::new(Bump::new())),
|
||||
recycled: Default::default(),
|
||||
}
|
||||
}
|
||||
|
@ -638,7 +634,7 @@ impl Store {
|
|||
if let Some(location) = self.recycled.borrow_mut().pop() {
|
||||
location
|
||||
} else {
|
||||
let data: &'static MemoryLocationInner = self.bump.alloc(MemoryLocationInner {
|
||||
let data: &'static MemoryLocationInner = Box::leak(Box::new(MemoryLocationInner {
|
||||
data: RefCell::new(None),
|
||||
#[cfg(any(debug_assertions, feature = "check_generation"))]
|
||||
generation: Cell::new(0),
|
||||
|
@ -646,7 +642,7 @@ impl Store {
|
|||
borrowed_at: Default::default(),
|
||||
#[cfg(any(debug_assertions, feature = "debug_borrows"))]
|
||||
borrowed_mut_at: Default::default(),
|
||||
});
|
||||
}));
|
||||
MemoryLocation(data)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue