Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ jobs:
- name: Run tests
run: cargo test --release

- name: Run integration tests
run: cargo test --release --test integration

msys2-build-test:
strategy:
fail-fast: false
Expand Down Expand Up @@ -183,3 +186,6 @@ jobs:
- name: Run tests
run: cargo test --release

- name: Run integration tests
run: cargo test --release --test integration

24 changes: 18 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/typed_indexmap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ doctest = false

[dependencies]
indexmap = "2.0"
ahash = "0.8"
rustc-hash = "2.0"
26 changes: 16 additions & 10 deletions lib/typed_indexmap/src/map.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::fmt::Debug;
use std::hash::Hash;
use std::hash::{BuildHasherDefault, Hash};
use std::iter;
use std::marker::PhantomData;
use std::ops::{Index, IndexMut};

use ahash::RandomState;
use indexmap::{Equivalent, IndexMap};
use rustc_hash::FxHasher;

pub type Iter<'a, I, K, V> = iter::Map<
iter::Enumerate<indexmap::map::Iter<'a, K, V>>,
Expand All @@ -15,7 +15,7 @@ pub type Iter<'a, I, K, V> = iter::Map<
#[repr(transparent)]
pub struct TiMap<I, K, V> {
/// raw set property
pub raw: IndexMap<K, V, ahash::RandomState>,
pub raw: IndexMap<K, V, BuildHasherDefault<FxHasher>>,
_marker: PhantomData<fn(I) -> I>,
}

Expand All @@ -38,7 +38,10 @@ impl<I, K: Clone, V: Clone> Clone for TiMap<I, K, V> {

impl<I, K, V> Default for TiMap<I, K, V> {
fn default() -> Self {
Self { raw: IndexMap::default(), _marker: PhantomData }
Self {
raw: IndexMap::with_hasher(BuildHasherDefault::<FxHasher>::default()),
_marker: PhantomData,
}
}
}

Expand Down Expand Up @@ -75,7 +78,7 @@ impl<I, K, V> TiMap<I, K, V> {

pub fn with_capacity(cap: usize) -> Self {
Self {
raw: IndexMap::with_capacity_and_hasher(cap, RandomState::new()),
raw: IndexMap::with_capacity_and_hasher(cap, BuildHasherDefault::<FxHasher>::default()),
_marker: PhantomData,
}
}
Expand Down Expand Up @@ -177,21 +180,24 @@ where
}
}

impl<I, K, V> From<IndexMap<K, V, ahash::RandomState>> for TiMap<I, K, V> {
fn from(raw: IndexMap<K, V, ahash::RandomState>) -> Self {
impl<I, K, V> From<IndexMap<K, V, BuildHasherDefault<FxHasher>>> for TiMap<I, K, V> {
fn from(raw: IndexMap<K, V, BuildHasherDefault<FxHasher>>) -> Self {
TiMap { raw, _marker: PhantomData }
}
}

impl<I, K: Hash + Eq, V> FromIterator<(K, V)> for TiMap<I, K, V> {
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
Self { raw: iter.into_iter().collect(), _marker: PhantomData }
let mut map = IndexMap::with_hasher(BuildHasherDefault::<FxHasher>::default());
map.extend(iter);
Self { raw: map, _marker: PhantomData }
}
}

impl<I, K, V> AsRef<TiMap<I, K, V>> for IndexMap<K, V, RandomState> {
impl<I, K, V> AsRef<TiMap<I, K, V>> for IndexMap<K, V, BuildHasherDefault<FxHasher>> {
fn as_ref(&self) -> &TiMap<I, K, V> {
let ptr = self as *const IndexMap<K, V, RandomState> as *const TiMap<I, K, V>;
let ptr =
self as *const IndexMap<K, V, BuildHasherDefault<FxHasher>> as *const TiMap<I, K, V>;
// safety: this is save because of repr(transparent)
unsafe { &*ptr }
}
Expand Down
16 changes: 11 additions & 5 deletions lib/typed_indexmap/src/set.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use std::fmt::Debug;
use std::hash::Hash;
use std::hash::{BuildHasherDefault, Hash};
use std::iter;
use std::marker::PhantomData;
use std::ops::Index;

use indexmap::{Equivalent, IndexSet};
use rustc_hash::FxHasher;

pub type Iter<'a, K, V> =
iter::Map<iter::Enumerate<indexmap::set::Iter<'a, V>>, fn((usize, &'a V)) -> (K, &'a V)>;

pub struct TiSet<K, V> {
/// raw set property
pub raw: IndexSet<V, ahash::RandomState>,
pub raw: IndexSet<V, BuildHasherDefault<FxHasher>>,
_marker: PhantomData<fn(K) -> K>,
}

Expand All @@ -33,14 +34,17 @@ impl<K, V: Clone> Clone for TiSet<K, V> {

impl<K, V> Default for TiSet<K, V> {
fn default() -> Self {
Self { raw: IndexSet::default(), _marker: PhantomData }
Self {
raw: IndexSet::with_hasher(BuildHasherDefault::<FxHasher>::default()),
_marker: PhantomData,
}
}
}

impl<K, V> TiSet<K, V> {
pub fn with_capacity(cap: usize) -> TiSet<K, V> {
TiSet {
raw: IndexSet::with_capacity_and_hasher(cap, ahash::RandomState::default()),
raw: IndexSet::with_capacity_and_hasher(cap, BuildHasherDefault::<FxHasher>::default()),
_marker: PhantomData,
}
}
Expand Down Expand Up @@ -174,6 +178,8 @@ where
V: Eq + Hash,
{
fn from_iter<T: IntoIterator<Item = V>>(iter: T) -> Self {
Self { raw: iter.into_iter().collect(), _marker: PhantomData }
let mut set = IndexSet::with_hasher(BuildHasherDefault::<FxHasher>::default());
set.extend(iter);
Self { raw: set, _marker: PhantomData }
}
}
4 changes: 2 additions & 2 deletions melange/core/src/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ impl Circuit {
eval_ctx: ExprEvalCtxRef,
arena: &Arena,
config: SimConfig,
) -> Result<Simulation> {
) -> Result<Simulation<'_>> {
let mut res = self.setup_simulation(config)?;
res.prepare_solver(eval_ctx, arena)?;
Ok(res)
}

pub fn setup_simulation(&self, config: SimConfig) -> Result<Simulation> {
pub fn setup_simulation(&self, config: SimConfig) -> Result<Simulation<'_>> {
let model_data: Box<TiSlice<_, _>> = self
.models()
.map(|model| {
Expand Down
1 change: 1 addition & 0 deletions openvaf/basedb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ typed-index-collections = "3.1"
parking_lot = "0.12"
indexmap = "2.0"
ahash = "0.8"
rustc-hash = "2.0"

[dev-dependencies]
expect-test = "1.4"
Expand Down
4 changes: 3 additions & 1 deletion openvaf/basedb/src/lints.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::fmt::{self, Display, Formatter};
use std::hash::BuildHasherDefault;
use std::sync::Arc;

use indexmap::IndexMap;
use rustc_hash::FxHasher;
use stdx::{impl_debug_display, impl_idx_from};
use vfs::FileId;

Expand Down Expand Up @@ -101,7 +103,7 @@ pub struct LintData {
/// and `str (lint name) -> LintData`
#[derive(Debug, Default, Eq, PartialEq)]
pub struct LintRegistry {
lints: IndexMap<&'static str, LintData, ahash::RandomState>,
lints: IndexMap<&'static str, LintData, BuildHasherDefault<FxHasher>>,
}

impl LintRegistry {
Expand Down
1 change: 1 addition & 0 deletions openvaf/hir_def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typed-index-collections = "3.1"

# Performant collections
ahash = "0.8"
rustc-hash = "2.0"
indexmap = "2.0"

[dev-dependencies]
Expand Down
10 changes: 7 additions & 3 deletions openvaf/hir_def/src/builtin.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! Generated by `generate_builtins`, do not edit by hand.

use ahash::RandomState;
use std::hash::BuildHasherDefault;

use indexmap::IndexMap;
use rustc_hash::FxHasher;
use syntax::name::{kw, sysfun, Name};

use crate::nameres::ScopeDefItem;
Expand Down Expand Up @@ -238,7 +240,7 @@ impl BuiltIn {
}
}
}
pub fn insert_builtin_scope(dst: &mut IndexMap<Name, ScopeDefItem, RandomState>) {
pub fn insert_builtin_scope(dst: &mut IndexMap<Name, ScopeDefItem, BuildHasherDefault<FxHasher>>) {
dst.insert(kw::abs, BuiltIn::abs.into());
dst.insert(kw::acos, BuiltIn::acos.into());
dst.insert(kw::acosh, BuiltIn::acosh.into());
Expand Down Expand Up @@ -371,7 +373,9 @@ pub fn insert_builtin_scope(dst: &mut IndexMap<Name, ScopeDefItem, RandomState>)
dst.insert(kw::slew, BuiltIn::slew.into());
dst.insert(kw::transition, BuiltIn::transition.into());
}
pub fn insert_module_builtin_scope(dst: &mut IndexMap<Name, ScopeDefItem, RandomState>) {
pub fn insert_module_builtin_scope(
dst: &mut IndexMap<Name, ScopeDefItem, BuildHasherDefault<FxHasher>>,
) {
dst.insert(sysfun::mfactor, ParamSysFun::mfactor.into());
dst.insert(sysfun::xposition, ParamSysFun::xposition.into());
dst.insert(sysfun::yposition, ParamSysFun::yposition.into());
Expand Down
Loading
Loading