Skip to content

Commit 16dab53

Browse files
authored
perf: using FxHashMap instead of HashMap (#83)
1 parent 2b9782d commit 16dab53

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ scroll = { version = "0.10.1", features = ["derive"], optional = true }
3333
data-encoding = "2.3.3"
3434
debugid = {version = "0.8.0", features = ["serde"] }
3535
base64-simd = { version = "0.7" }
36+
rustc-hash = "1.1.0"
3637

3738
[build-dependencies]
3839
rustc_version = "0.2.3"

src/builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#![cfg_attr(not(any(unix, windows, target_os = "redox")), allow(unused_imports))]
22

3-
use std::collections::HashMap;
43
use std::convert::AsRef;
54
use std::env;
65
use std::fs;
76
use std::io::Read;
87
use std::path::{Path, PathBuf};
98

109
use debugid::DebugId;
10+
use rustc_hash::FxHashMap;
1111
use url::Url;
1212

1313
use crate::errors::Result;
@@ -20,10 +20,10 @@ use crate::types::{RawToken, SourceMap, Token};
2020
/// type can help.
2121
pub struct SourceMapBuilder {
2222
file: Option<String>,
23-
name_map: HashMap<String, u32>,
23+
name_map: FxHashMap<String, u32>,
2424
names: Vec<String>,
2525
tokens: Vec<RawToken>,
26-
source_map: HashMap<String, u32>,
26+
source_map: FxHashMap<String, u32>,
2727
source_root: Option<String>,
2828
sources: Vec<String>,
2929
source_contents: Vec<Option<String>>,
@@ -53,10 +53,10 @@ impl SourceMapBuilder {
5353
pub fn new(file: Option<&str>) -> SourceMapBuilder {
5454
SourceMapBuilder {
5555
file: file.map(str::to_owned),
56-
name_map: HashMap::new(),
56+
name_map: FxHashMap::default(),
5757
names: vec![],
5858
tokens: vec![],
59-
source_map: HashMap::new(),
59+
source_map: FxHashMap::default(),
6060
source_root: None,
6161
sources: vec![],
6262
source_contents: vec![],

0 commit comments

Comments
 (0)