mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-08-15 23:00:46 +03:00
Change to use index structures
This commit is contained in:
parent
b5721e48e2
commit
37a7a0f2e1
@ -3,9 +3,8 @@ mod order_kwargs;
|
|||||||
pub mod parser;
|
pub mod parser;
|
||||||
pub mod to_fun;
|
pub mod to_fun;
|
||||||
|
|
||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
use crate::fun::{CtrField, Name, Num, Op};
|
use crate::fun::{CtrField, Name, Num, Op};
|
||||||
|
use indexmap::{IndexMap, IndexSet};
|
||||||
use interner::global::GlobalString;
|
use interner::global::GlobalString;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@ -240,12 +239,12 @@ impl InPlaceOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait RepeatedNames {
|
pub trait RepeatedNames {
|
||||||
fn find_repeated_names(&self) -> HashSet<Name>;
|
fn find_repeated_names(&self) -> IndexSet<Name>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RepeatedNames for Vec<CtrField> {
|
impl RepeatedNames for Vec<CtrField> {
|
||||||
fn find_repeated_names(&self) -> HashSet<Name> {
|
fn find_repeated_names(&self) -> IndexSet<Name> {
|
||||||
let mut count = std::collections::HashMap::new();
|
let mut count = IndexMap::new();
|
||||||
for field in self.iter() {
|
for field in self.iter() {
|
||||||
*count.entry(field.nam.clone()).or_insert(0) += 1;
|
*count.entry(field.nam.clone()).or_insert(0) += 1;
|
||||||
}
|
}
|
||||||
@ -254,7 +253,7 @@ impl RepeatedNames for Vec<CtrField> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RepeatedNames for Variant {
|
impl RepeatedNames for Variant {
|
||||||
fn find_repeated_names(&self) -> HashSet<Name> {
|
fn find_repeated_names(&self) -> IndexSet<Name> {
|
||||||
self.fields.find_repeated_names()
|
self.fields.find_repeated_names()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user