Skip to content

Commit

Permalink
perf: using FxHashMap instead of HashMap (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin authored Mar 15, 2024
1 parent 2b9782d commit 16dab53
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ scroll = { version = "0.10.1", features = ["derive"], optional = true }
data-encoding = "2.3.3"
debugid = {version = "0.8.0", features = ["serde"] }
base64-simd = { version = "0.7" }
rustc-hash = "1.1.0"

[build-dependencies]
rustc_version = "0.2.3"
Expand Down
10 changes: 5 additions & 5 deletions src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#![cfg_attr(not(any(unix, windows, target_os = "redox")), allow(unused_imports))]

use std::collections::HashMap;
use std::convert::AsRef;
use std::env;
use std::fs;
use std::io::Read;
use std::path::{Path, PathBuf};

use debugid::DebugId;
use rustc_hash::FxHashMap;
use url::Url;

use crate::errors::Result;
Expand All @@ -20,10 +20,10 @@ use crate::types::{RawToken, SourceMap, Token};
/// type can help.
pub struct SourceMapBuilder {
file: Option<String>,
name_map: HashMap<String, u32>,
name_map: FxHashMap<String, u32>,
names: Vec<String>,
tokens: Vec<RawToken>,
source_map: HashMap<String, u32>,
source_map: FxHashMap<String, u32>,
source_root: Option<String>,
sources: Vec<String>,
source_contents: Vec<Option<String>>,
Expand Down Expand Up @@ -53,10 +53,10 @@ impl SourceMapBuilder {
pub fn new(file: Option<&str>) -> SourceMapBuilder {
SourceMapBuilder {
file: file.map(str::to_owned),
name_map: HashMap::new(),
name_map: FxHashMap::default(),
names: vec![],
tokens: vec![],
source_map: HashMap::new(),
source_map: FxHashMap::default(),
source_root: None,
sources: vec![],
source_contents: vec![],
Expand Down

0 comments on commit 16dab53

Please sign in to comment.