Skip to content

Commit

Permalink
chore(atoms): Evaluate .into() in AtomStoreCell eagerly (#8363)
Browse files Browse the repository at this point in the history
**Related issue:** 

 - Closes #8362
  • Loading branch information
dsherret authored Dec 1, 2023
1 parent d0a885d commit 1e8edb4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/swc_atoms/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ pub struct AtomStoreCell(UnsafeCell<AtomStore>);
impl AtomStoreCell {
#[inline]
pub fn atom<'a>(&self, s: impl Into<Cow<'a, str>>) -> Atom {
// evaluate the into before borrowing (see #8362)
let s: Cow<'a, str> = s.into();
// SAFETY: We can skip the borrow check of RefCell because
// this API enforces a safe contract. It is slightly faster
// to use an UnsafeCell. Note the borrow here is short lived
Expand Down

0 comments on commit 1e8edb4

Please sign in to comment.