فهرست منبع

remove bump in generational box

Evan Almloff 1 سال پیش
والد
کامیت
65c0d213e3
2فایلهای تغییر یافته به همراه2 افزوده شده و 7 حذف شده
  1. 0 1
      packages/generational-box/Cargo.toml
  2. 2 6
      packages/generational-box/src/lib.rs

+ 0 - 1
packages/generational-box/Cargo.toml

@@ -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"

+ 2 - 6
packages/generational-box/src/lib.rs

@@ -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)
         }
     }