Change some runtime maps to be HashMap instead of BTreeMap
This should hypothetically be faster, but we'll see how that plays out. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
use crate::obj::{sym::Sym, ObjRef};
|
use crate::obj::{sym::Sym, ObjRef};
|
||||||
use shredder::{Gc, Scan};
|
use shredder::{Gc, Scan};
|
||||||
use std::{
|
use std::{
|
||||||
collections::BTreeMap,
|
collections::HashMap,
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type Attrs = BTreeMap<Sym, ObjRef>;
|
pub type Attrs = HashMap<Sym, ObjRef>;
|
||||||
pub type VtableAttrs = Gc<Attrs>;
|
pub type VtableAttrs = Gc<Attrs>;
|
||||||
|
|
||||||
#[derive(Scan, Debug, Clone, Default)]
|
#[derive(Scan, Debug, Clone, Default)]
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ use crate::{
|
|||||||
obj::{prelude::*, reserved::*},
|
obj::{prelude::*, reserved::*},
|
||||||
vm::{error::*, signal::*},
|
vm::{error::*, signal::*},
|
||||||
};
|
};
|
||||||
use maplit::btreemap;
|
use maplit::hashmap;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Builtin free functions
|
// Builtin free functions
|
||||||
@@ -74,8 +74,8 @@ pub static PRINT_BUILTIN_FUN: Lazy<NativeFunRef> = Lazy::new(|| {
|
|||||||
// Builtin objects
|
// Builtin objects
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
pub static BUILTIN_OBJS: Lazy<BTreeMap<Sym, ObjRef>> = Lazy::new(|| {
|
pub static BUILTIN_OBJS: Lazy<HashMap<Sym, ObjRef>> = Lazy::new(|| {
|
||||||
btreemap! {
|
hashmap! {
|
||||||
PRINTLN_BUILTIN_NAME.sym => PRINTLN_BUILTIN_FUN.clone() as _,
|
PRINTLN_BUILTIN_NAME.sym => PRINTLN_BUILTIN_FUN.clone() as _,
|
||||||
PRINT_BUILTIN_NAME.sym => PRINT_BUILTIN_FUN.clone() as _,
|
PRINT_BUILTIN_NAME.sym => PRINT_BUILTIN_FUN.clone() as _,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ impl UserFun {
|
|||||||
&self.locals
|
&self.locals
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Dump this function's code to the given writer.
|
||||||
pub fn dump(
|
pub fn dump(
|
||||||
&self,
|
&self,
|
||||||
writer: &mut dyn Write,
|
writer: &mut dyn Write,
|
||||||
|
|||||||
@@ -86,22 +86,22 @@ macro_rules! read_obj_downcast {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! attrs {
|
macro_rules! attrs {
|
||||||
($($key:expr => $value:expr),+ $(,)?) => {{
|
($($key:expr => $value:expr),+ $(,)?) => {{
|
||||||
maplit::btreemap! { $($key => ($value as _) ),+ }
|
maplit::hashmap! { $($key => ($value as _) ),+ }
|
||||||
}};
|
}};
|
||||||
|
|
||||||
() => {{
|
() => {{
|
||||||
maplit::btreemap! { }
|
maplit::hashmap! { }
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! vtable {
|
macro_rules! vtable {
|
||||||
($($key:expr => $value:expr),+ $(,)?) => {{
|
($($key:expr => $value:expr),+ $(,)?) => {{
|
||||||
$crate::obj::attrs::Vtable::new(maplit::btreemap! { $($key => ($value as _) ),+ })
|
$crate::obj::attrs::Vtable::new(maplit::hashmap! { $($key => ($value as _) ),+ })
|
||||||
}};
|
}};
|
||||||
|
|
||||||
() => {{
|
() => {{
|
||||||
$crate::obj::attrs::Vtable::new(maplit::btreemap! { })
|
$crate::obj::attrs::Vtable::new(maplit::hashmap! { })
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::obj::{intern::Interner, prelude::*, reserved::*};
|
use crate::obj::{intern::Interner, prelude::*, reserved::*};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::{
|
use std::{
|
||||||
collections::BTreeMap,
|
collections::HashMap,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ pub static SYM_VTABLE: Lazy<Vtable> = Lazy::new(|| vtable! {});
|
|||||||
//
|
//
|
||||||
// global interned symbol obj table
|
// global interned symbol obj table
|
||||||
//
|
//
|
||||||
pub(crate) static SYM_REFS: Lazy<Mutex<BTreeMap<Sym, SymRef>>> = Lazy::new(|| Default::default());
|
pub(crate) static SYM_REFS: Lazy<Mutex<HashMap<Sym, SymRef>>> = Lazy::new(|| Default::default());
|
||||||
|
|
||||||
/// Access or insert a globally interned symbol object.
|
/// Access or insert a globally interned symbol object.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use crate::{obj::prelude::*, vm::inst::Inst};
|
use crate::{obj::prelude::*, vm::inst::Inst};
|
||||||
use std::fmt::{self, Debug, Formatter};
|
use std::fmt::{self, Debug, Formatter};
|
||||||
use std::{collections::BTreeMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
|
|
||||||
pub type FrameBindings = BTreeMap<usize, ObjRef>;
|
pub type FrameBindings = HashMap<usize, ObjRef>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Frame {
|
pub enum Frame {
|
||||||
|
|||||||
Reference in New Issue
Block a user