replaced Box<str> with SmolStr

This commit is contained in:
Moritz Gmeiner 2024-09-02 05:19:30 +02:00
commit da6a820638
21 changed files with 137 additions and 85 deletions

View file

@ -3,6 +3,7 @@ use std::rc::Rc;
use rlox2_frontend::parser::{Expr, Stmt};
use rustc_hash::FxHashMap;
use smol_str::SmolStr;
use crate::{LoxFunction, LoxReference, Value};
@ -10,7 +11,7 @@ use crate::{LoxFunction, LoxReference, Value};
pub struct LoxClass {
superclass: Option<Rc<LoxClass>>,
name: Box<str>,
name: SmolStr,
methods: FxHashMap<String, Value>,
}
@ -18,7 +19,7 @@ pub struct LoxClass {
/// Representation of a class in Lox. Always behind an Rc to ensure uniqueness. Should never be handled raw.
impl LoxClass {
pub fn new(
name: impl Into<Box<str>>,
name: impl Into<SmolStr>,
methods: FxHashMap<String, Value>,
superclass: Option<Rc<LoxClass>>,
) -> Rc<Self> {