diff options
author | sharkdp <davidpeter@web.de> | 2020-06-03 10:11:49 +0200 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2020-06-03 19:44:41 +0200 |
commit | 9f52012443bb3f46fd136bcc1c45978a26662111 (patch) | |
tree | e6ee59ded894de98fed4107e2a71b44c7a92a48d /src | |
parent | e57e9b6dbbc7e26692399547be8cf17c2f891021 (diff) |
Prevent allocation of additional Strings
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/bat/main.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index 3882edc7..a643d3e5 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -62,15 +62,15 @@ fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> { Ok(()) } -fn get_syntax_mapping_to_paths( - mappings: &[(GlobMatcher, MappingTarget)], -) -> HashMap<String, Vec<String>> { - let mut map: HashMap<String, Vec<String>> = HashMap::new(); +fn get_syntax_mapping_to_paths<'a>( + mappings: &[(GlobMatcher, MappingTarget<'a>)], +) -> HashMap<&'a str, Vec<String>> { + let mut map: HashMap<&str, Vec<String>> = HashMap::new(); for mapping in mappings { match mapping { (_, MappingTarget::MapToUnknown) => {} (matcher, MappingTarget::MapTo(s)) => { - let globs = map.entry((*s).into()).or_insert_with(Vec::new); + let globs = map.entry(s).or_insert_with(Vec::new); globs.push(matcher.glob().glob().into()); } } @@ -91,7 +91,7 @@ pub fn list_languages(config: &Config) -> Result<()> { let configured_languages = get_syntax_mapping_to_paths(config.syntax_mapping.mappings()); for lang in languages.iter_mut() { - if let Some(additional_paths) = configured_languages.get(&lang.name) { + if let Some(additional_paths) = configured_languages.get(lang.name.as_str()) { lang.file_extensions .extend(additional_paths.iter().cloned()); } |