refactor(hir): use Cell for SymbolId instead of RefCell

This commit is contained in:
Boshen 2023-06-19 20:23:46 +08:00
parent d30735677b
commit 527b94fba6
No known key found for this signature in database
GPG key ID: 9C7A8C8AB22BEBD1
2 changed files with 5 additions and 5 deletions

View file

@ -1,5 +1,5 @@
use std::{
cell::RefCell,
cell::Cell,
fmt,
hash::{Hash, Hasher},
};
@ -407,7 +407,7 @@ pub struct IdentifierReference {
pub span: Span,
pub name: Atom,
#[cfg_attr(feature = "serde", serde(skip))]
pub reference_id: RefCell<ReferenceId>,
pub reference_id: Cell<ReferenceId>,
}
impl Hash for IdentifierReference {
@ -424,7 +424,7 @@ pub struct BindingIdentifier {
pub span: Span,
pub name: Atom,
#[cfg_attr(feature = "serde", serde(skip))]
pub symbol_id: RefCell<SymbolId>,
pub symbol_id: Cell<SymbolId>,
}
impl Hash for BindingIdentifier {

View file

@ -85,13 +85,13 @@ impl<'a> Visit<'a> for ManglerBuilder<'a> {
) {
let symbol_id =
self.semantic.declare_symbol_for_mangler(ident.span, &ident.name, includes, excludes);
*ident.symbol_id.borrow_mut() = symbol_id;
ident.symbol_id.replace(symbol_id);
}
fn visit_identifier_reference(&mut self, ident: &'a IdentifierReference) {
let reference = Reference::new(ident.span, ident.name.clone(), ReferenceFlag::read());
let reference_id = self.semantic.declare_reference(reference);
*ident.reference_id.borrow_mut() = reference_id;
ident.reference_id.replace(reference_id);
}
}