Skip to content

Commit 960f244

Browse files
committed
refactor(llvm): replace HashMap with BTreeMap
1 parent 67687fc commit 960f244

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

hugr-llvm/src/custom/extension_op.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{collections::HashMap, rc::Rc};
1+
use std::{collections::BTreeMap, rc::Rc};
22

33
use hugr_core::{
44
HugrView, Node,
@@ -56,7 +56,7 @@ impl<
5656
///
5757
/// Those callbacks may hold references with lifetimes older than `'a`.
5858
#[derive(Default)]
59-
pub struct ExtensionOpMap<'a, H>(HashMap<(ExtensionId, OpName), Box<dyn ExtensionOpFn<'a, H>>>);
59+
pub struct ExtensionOpMap<'a, H>(BTreeMap<(ExtensionId, OpName), Box<dyn ExtensionOpFn<'a, H>>>);
6060

6161
impl<'a, H: HugrView<Node = Node>> ExtensionOpMap<'a, H> {
6262
/// Register a callback to emit a [`ExtensionOp`], keyed by fully

hugr-llvm/src/custom/load_constant.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Provides the implementation for a collection of [`CustomConst`] callbacks.
2-
use std::{any::TypeId, collections::HashMap};
2+
use std::{any::TypeId, collections::BTreeMap};
33

44
use hugr_core::{HugrView, Node, ops::constant::CustomConst};
55
use inkwell::values::BasicValueEnum;
@@ -36,7 +36,7 @@ impl<
3636
/// The callbacks are keyed by the [`TypeId`] of those impls.
3737
#[derive(Default)]
3838
pub struct LoadConstantsMap<'a, H>(
39-
HashMap<TypeId, Box<dyn LoadConstantFn<'a, H, dyn CustomConst>>>,
39+
BTreeMap<TypeId, Box<dyn LoadConstantFn<'a, H, dyn CustomConst>>>,
4040
);
4141

4242
impl<'a, H: HugrView<Node = Node>> LoadConstantsMap<'a, H> {

hugr-llvm/src/emit/func.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{collections::HashMap, rc::Rc};
1+
use std::{collections::BTreeMap, rc::Rc};
22

33
use anyhow::{Result, anyhow};
44
use hugr_core::{
@@ -51,7 +51,7 @@ where
5151
emit_context: EmitModuleContext<'c, 'a, H>,
5252
todo: EmissionSet,
5353
func: FunctionValue<'c>,
54-
env: HashMap<Wire, ValueMailBox<'c>>,
54+
env: BTreeMap<Wire, ValueMailBox<'c>>,
5555
builder: Builder<'c>,
5656
prologue_bb: BasicBlock<'c>,
5757
launch_bb: BasicBlock<'c>,

hugr-llvm/src/emit/ops/cfg.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::HashMap;
1+
use std::collections::BTreeMap;
22

33
use anyhow::{Result, anyhow};
44
use hugr_core::{
@@ -21,7 +21,7 @@ use crate::{
2121
use super::emit_dataflow_parent;
2222

2323
pub struct CfgEmitter<'c, 'hugr, H> {
24-
bbs: HashMap<FatNode<'hugr, OpType, H>, (BasicBlock<'c>, RowMailBox<'c>)>,
24+
bbs: BTreeMap<FatNode<'hugr, OpType, H>, (BasicBlock<'c>, RowMailBox<'c>)>,
2525
inputs: Option<Vec<BasicValueEnum<'c>>>,
2626
outputs: Option<RowPromise<'c>>,
2727
node: FatNode<'hugr, CFG, H>,
@@ -47,7 +47,7 @@ impl<'c, 'hugr, H: HugrView<Node = Node>> CfgEmitter<'c, 'hugr, H> {
4747
// to crate the other blocks immediately before it. This is just for
4848
// nice block ordering.
4949
let exit_block = context.new_basic_block("", None);
50-
let mut bbs = HashMap::new();
50+
let mut bbs = BTreeMap::new();
5151
for child in node.children() {
5252
if child.is_exit_block() {
5353
let output_row = {

hugr-llvm/src/utils/type_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Provides a generic mapping from [`HugrType`] into some domain.
2-
use std::collections::HashMap;
2+
use std::collections::BTreeMap;
33

44
use hugr_core::{
55
extension::ExtensionId,
@@ -94,7 +94,7 @@ pub type CustomTypeKey = (ExtensionId, TypeName);
9494
#[derive(Default)]
9595
pub struct TypeMap<'a, TM: TypeMapping> {
9696
type_map: TM,
97-
custom_hooks: HashMap<CustomTypeKey, Box<dyn TypeMappingFn<'a, TM> + 'a>>,
97+
custom_hooks: BTreeMap<CustomTypeKey, Box<dyn TypeMappingFn<'a, TM> + 'a>>,
9898
}
9999

100100
impl<'a, TM: TypeMapping + 'a> TypeMap<'a, TM> {

0 commit comments

Comments
 (0)