Skip to content

Commit 1e8edb4

Browse files
authored
chore(atoms): Evaluate .into() in AtomStoreCell eagerly (#8363)
**Related issue:** - Closes #8362
1 parent d0a885d commit 1e8edb4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

crates/swc_atoms/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ pub struct AtomStoreCell(UnsafeCell<AtomStore>);
238238
impl AtomStoreCell {
239239
#[inline]
240240
pub fn atom<'a>(&self, s: impl Into<Cow<'a, str>>) -> Atom {
241+
// evaluate the into before borrowing (see #8362)
242+
let s: Cow<'a, str> = s.into();
241243
// SAFETY: We can skip the borrow check of RefCell because
242244
// this API enforces a safe contract. It is slightly faster
243245
// to use an UnsafeCell. Note the borrow here is short lived

0 commit comments

Comments
 (0)