Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/filepatterns.rs @ 43844:5ac243a92e37
rust-performance: introduce FastHashMap type alias for HashMap
Rust's default hashing is slow, because it is meant for preventing collision
attacks.
For all of the current Rust code, we don't care about those attacks, because
if an person with bad intentions has write access to your repo, you have other
issues.
I've chosen to use the TwoXHash crate because it was made by a reputable member
of the Rust community and has very good benchmarks.
For now it does not seem to improve performance by much for the current code,
but it's something else to not worry about when benchmarking code: in a
previous experiment with copytracing in Rust, it accounted for more than 10%
of the time of the entire script.
Differential Revision: https://phab.mercurial-scm.org/D7116
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Mon, 14 Oct 2019 13:57:30 +0200 |
parents | 7a01778bc7b7 |
children | d42eea9a0494 |
line wrap: on
line diff
--- a/rust/hg-core/src/filepatterns.rs Mon Dec 02 14:44:26 2019 +0100 +++ b/rust/hg-core/src/filepatterns.rs Mon Oct 14 13:57:30 2019 +0200 @@ -7,10 +7,11 @@ //! Handling of Mercurial-specific patterns. -use crate::{utils::SliceExt, LineNumber, PatternError, PatternFileError}; +use crate::{ + utils::SliceExt, FastHashMap, LineNumber, PatternError, PatternFileError, +}; use lazy_static::lazy_static; use regex::bytes::{NoExpand, Regex}; -use std::collections::HashMap; use std::fs::File; use std::io::Read; use std::path::{Path, PathBuf}; @@ -214,8 +215,8 @@ } lazy_static! { - static ref SYNTAXES: HashMap<&'static [u8], &'static [u8]> = { - let mut m = HashMap::new(); + static ref SYNTAXES: FastHashMap<&'static [u8], &'static [u8]> = { + let mut m = FastHashMap::default(); m.insert(b"re".as_ref(), b"relre:".as_ref()); m.insert(b"regexp".as_ref(), b"relre:".as_ref());