feat: use hashbrown
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use std::collections::HashSet;
|
||||
use hashbrown::{HashMap, HashSet};
|
||||
|
||||
use derive_more::Constructor;
|
||||
use itertools::Itertools;
|
||||
use rpds::HashTrieMap;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::vm::{Env, VM};
|
||||
@@ -13,25 +12,25 @@ use super::Value;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Constructor, Clone, PartialEq)]
|
||||
pub struct AttrSet<'vm> {
|
||||
data: HashTrieMap<usize, Value<'vm>>,
|
||||
data: HashMap<usize, Value<'vm>>,
|
||||
}
|
||||
|
||||
impl<'vm> AttrSet<'vm> {
|
||||
pub fn empty() -> Self {
|
||||
AttrSet {
|
||||
data: HashTrieMap::new(),
|
||||
data: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn push_attr_force(&mut self, sym: usize, val: Value<'vm>) {
|
||||
self.data.insert_mut(sym, val);
|
||||
self.data.insert(sym, val);
|
||||
}
|
||||
|
||||
pub fn push_attr(&mut self, sym: usize, val: Value<'vm>) {
|
||||
if self.data.get(&sym).is_some() {
|
||||
todo!()
|
||||
}
|
||||
self.data.insert_mut(sym, val);
|
||||
self.data.insert(sym, val);
|
||||
}
|
||||
|
||||
pub fn select(&self, sym: usize) -> Option<Value<'vm>> {
|
||||
@@ -57,11 +56,11 @@ impl<'vm> AttrSet<'vm> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_inner(&self) -> &HashTrieMap<usize, Value<'vm>> {
|
||||
pub fn as_inner(&self) -> &HashMap<usize, Value<'vm>> {
|
||||
&self.data
|
||||
}
|
||||
|
||||
pub fn from_inner(data: HashTrieMap<usize, Value<'vm>>) -> Self {
|
||||
pub fn from_inner(data: HashMap<usize, Value<'vm>>) -> Self {
|
||||
Self { data }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::collections::HashSet;
|
||||
use hashbrown::HashSet;
|
||||
|
||||
use derive_more::Constructor;
|
||||
use rpds::Vector;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::cell::OnceCell;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashSet;
|
||||
use hashbrown::HashSet;
|
||||
use std::hash::Hash;
|
||||
use std::rc::Rc;
|
||||
|
||||
@@ -219,11 +219,11 @@ impl<'vm> Value<'vm> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn eq(self, other: Self) -> Self {
|
||||
pub fn eq(self, other: Self, vm: &'vm VM<'_>) -> Self {
|
||||
use Const::Bool;
|
||||
match (self, other) {
|
||||
(x @ Value::Catchable(_), _) | (_, x @ Value::Catchable(_)) => x,
|
||||
(s, other) => VmConst(Bool(s == other)),
|
||||
(s, other) => VmConst(Bool(s.eq_impl(&other, vm))),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use hashbrown::HashMap;
|
||||
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
|
||||
use std::ops::Deref;
|
||||
use std::sync::LazyLock;
|
||||
@@ -5,7 +6,7 @@ use std::sync::LazyLock;
|
||||
use derive_more::{Constructor, IsVariant, Unwrap};
|
||||
use ecow::EcoString;
|
||||
use regex::Regex;
|
||||
use rpds::{HashTrieMap, VectorSync};
|
||||
use rpds::VectorSync;
|
||||
|
||||
use super::common::*;
|
||||
|
||||
@@ -59,7 +60,7 @@ impl Symbol {
|
||||
|
||||
#[derive(Constructor, Clone, PartialEq)]
|
||||
pub struct AttrSet {
|
||||
data: HashTrieMap<Symbol, Value>,
|
||||
data: HashMap<Symbol, Value>,
|
||||
}
|
||||
|
||||
impl Debug for AttrSet {
|
||||
|
||||
Reference in New Issue
Block a user