Skip to content

Commit

Permalink
Remove cell
Browse files Browse the repository at this point in the history
  • Loading branch information
richarddavison committed Oct 10, 2024
1 parent 909d347 commit 8705649
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/src/class/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl ClassId {
let type_id = self.init_type_id();
let key = ClassIdKey(rt, type_id);

let opaque = unsafe { &(*qjs::JS_GetRuntimeOpaque(rt).cast::<Opaque>()) };
let opaque = unsafe { &mut (*qjs::JS_GetRuntimeOpaque(rt).cast::<Opaque>()) };

let id = opaque.get_class_id_map().entry(key).or_insert_with(|| {
let mut id = 0;
Expand Down
10 changes: 5 additions & 5 deletions core/src/runtime/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub(crate) struct Opaque<'js> {
/// The user provided interrupt handler, if any.
interrupt_handler: UnsafeCell<Option<InterruptHandler>>,

class_id_map: UnsafeCell<HashMap<ClassIdKey, qjs::JSClassID>>,
class_id_map: HashMap<ClassIdKey, qjs::JSClassID>,

userdata: UserDataMap,

Expand All @@ -48,7 +48,7 @@ impl<'js> Opaque<'js> {
Opaque {
panic: Cell::new(None),
interrupt_handler: UnsafeCell::new(None),
class_id_map: UnsafeCell::new(HashMap::new()),
class_id_map: HashMap::new(),
userdata: UserDataMap::default(),
#[cfg(feature = "futures")]
spawner: None,
Expand All @@ -61,7 +61,7 @@ impl<'js> Opaque<'js> {
Opaque {
panic: Cell::new(None),
interrupt_handler: UnsafeCell::new(None),
class_id_map: UnsafeCell::new(HashMap::new()),
class_id_map: HashMap::new(),
userdata: UserDataMap::default(),
#[cfg(feature = "futures")]
spawner: Some(UnsafeCell::new(Spawner::new())),
Expand Down Expand Up @@ -133,7 +133,7 @@ impl<'js> Opaque<'js> {
self.panic.take()
}

pub(crate) fn get_class_id_map(&self) -> &mut HashMap<ClassIdKey, u32> {
unsafe { &mut *self.class_id_map.get() }
pub(crate) fn get_class_id_map(&mut self) -> &mut HashMap<ClassIdKey, u32> {
&mut self.class_id_map
}
}

0 comments on commit 8705649

Please sign in to comment.