Skip to content

Commit

Permalink
refactor(semantic): SymbolTable::set_name return old name
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Dec 14, 2024
1 parent 9cb68fa commit 1f0673c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/oxc_semantic/src/symbol.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::mem;

#[cfg(feature = "serialize")]
use serde::Serialize;
#[cfg(feature = "serialize")]
Expand Down Expand Up @@ -101,9 +103,11 @@ impl SymbolTable {
}

/// Rename a symbol.
///
/// Returns the old name.
#[inline]
pub fn set_name(&mut self, symbol_id: SymbolId, name: CompactStr) {
self.names[symbol_id] = name;
pub fn set_name(&mut self, symbol_id: SymbolId, name: CompactStr) -> CompactStr {
mem::replace(&mut self.names[symbol_id], name)
}

/// Get the [`SymbolFlags`] for a symbol, which describe how the symbol is declared.
Expand Down

0 comments on commit 1f0673c

Please sign in to comment.