mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
replaced Box<str> with SmolStr
This commit is contained in:
parent
fb88595b6c
commit
da6a820638
21 changed files with 137 additions and 85 deletions
|
|
@ -4,6 +4,7 @@ use std::io::{stdin, stdout, Read, Write};
|
|||
use std::rc::Rc;
|
||||
|
||||
use rustc_hash::FxHashMap;
|
||||
use smol_str::SmolStr;
|
||||
|
||||
use crate::error::RuntimeError;
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ use super::lox_std::init_std;
|
|||
use super::Value;
|
||||
|
||||
pub struct Runtime {
|
||||
globals: FxHashMap<Box<str>, Value>,
|
||||
globals: FxHashMap<SmolStr, Value>,
|
||||
|
||||
in_stream: Rc<RefCell<dyn std::io::Read>>,
|
||||
out_stream: Rc<RefCell<dyn std::io::Write>>,
|
||||
|
|
@ -53,7 +54,7 @@ impl Runtime {
|
|||
self.out_stream.as_ref().borrow_mut()
|
||||
}
|
||||
|
||||
pub fn globals(&self) -> &FxHashMap<Box<str>, Value> {
|
||||
pub fn globals(&self) -> &FxHashMap<SmolStr, Value> {
|
||||
&self.globals
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ impl Runtime {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn define_global(&mut self, name: impl Into<Box<str>>, value: Value) {
|
||||
pub fn define_global(&mut self, name: impl Into<SmolStr>, value: Value) {
|
||||
let name = name.into();
|
||||
self.globals.insert(name, value);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue