mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
remove allocation in Symbol creation
This commit is contained in:
parent
9cb6261a4d
commit
813b22a106
5 changed files with 43 additions and 17 deletions
|
@ -634,9 +634,11 @@ impl IdentIds {
|
|||
/// This is used, for example, during canonicalization of an Expr::Closure
|
||||
/// to generate a unique symbol to refer to that closure.
|
||||
pub fn gen_unique(&mut self) -> IdentId {
|
||||
// TODO convert this directly from u32 into IdentStr,
|
||||
// without allocating an extra string along the way like this.
|
||||
let ident = self.next_generated_name.to_string().into();
|
||||
use std::fmt::Write;
|
||||
|
||||
let mut temp: arrayvec::ArrayString<15> = arrayvec::ArrayString::new();
|
||||
write!(temp, "{}", self.next_generated_name).unwrap();
|
||||
let ident = Ident(IdentStr::from_array_string(temp));
|
||||
|
||||
self.next_generated_name += 1;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue