Skip to content

Commit 688880c

Browse files
committed
Use ahash in the compiler
1 parent 0fe96f1 commit 688880c

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

Cargo.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ num-complex = { version = "0.3", features = ["serde"] }
1616
num-traits = "0.2"
1717
log = "0.4"
1818
arrayvec = "0.5"
19+
ahash = "0.6"
1920

2021
[dev-dependencies]
2122
rustpython-parser = { path = "../parser" }

compiler/src/compile.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::error::{CompileError, CompileErrorType};
99
use crate::ir::{self, CodeInfo};
1010
pub use crate::mode::Mode;
1111
use crate::symboltable::{make_symbol_table, statements_to_symbol_table, SymbolScope, SymbolTable};
12-
use indexmap::IndexSet;
12+
use crate::IndexSet;
1313
use itertools::Itertools;
1414
use num_complex::Complex64;
1515
use num_traits::ToPrimitive;
@@ -140,10 +140,10 @@ impl Compiler {
140140
blocks: vec![ir::Block::default()],
141141
current_block: bytecode::Label(0),
142142
constants: Vec::new(),
143-
name_cache: IndexSet::new(),
144-
varname_cache: IndexSet::new(),
145-
cellvar_cache: IndexSet::new(),
146-
freevar_cache: IndexSet::new(),
143+
name_cache: IndexSet::default(),
144+
varname_cache: IndexSet::default(),
145+
cellvar_cache: IndexSet::default(),
146+
freevar_cache: IndexSet::default(),
147147
};
148148
Compiler {
149149
code_stack: vec![module_code],
@@ -217,8 +217,8 @@ impl Compiler {
217217
blocks: vec![ir::Block::default()],
218218
current_block: bytecode::Label(0),
219219
constants: Vec::new(),
220-
name_cache: IndexSet::new(),
221-
varname_cache: IndexSet::new(),
220+
name_cache: IndexSet::default(),
221+
varname_cache: IndexSet::default(),
222222
cellvar_cache,
223223
freevar_cache,
224224
};

compiler/src/ir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use indexmap::IndexSet;
1+
use crate::IndexSet;
22
use rustpython_bytecode::{CodeFlags, CodeObject, ConstantData, Instruction, Label, Location};
33

44
pub type BlockIdx = Label;

compiler/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#[macro_use]
66
extern crate log;
77

8+
type IndexMap<K, V> = indexmap::IndexMap<K, V, ahash::RandomState>;
9+
type IndexSet<T> = indexmap::IndexSet<T, ahash::RandomState>;
10+
811
pub mod compile;
912
pub mod error;
1013
pub mod ir;

compiler/src/symboltable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Inspirational file: https://github.com/python/cpython/blob/master/Python/symtabl
88
*/
99

1010
use crate::error::{CompileError, CompileErrorType};
11-
use indexmap::map::IndexMap;
11+
use crate::IndexMap;
1212
use rustpython_ast::{self as ast, Location};
1313
use std::fmt;
1414

@@ -58,7 +58,7 @@ impl SymbolTable {
5858
typ,
5959
line_number,
6060
is_nested,
61-
symbols: IndexMap::new(),
61+
symbols: IndexMap::default(),
6262
sub_tables: vec![],
6363
}
6464
}

0 commit comments

Comments
 (0)