Use FxHash (#151)

This commit is contained in:
Charlie Marsh 2023-10-20 01:26:06 -04:00 committed by GitHub
parent 8001c792e7
commit 4645f79237
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 48 additions and 43 deletions

View file

@ -1,21 +1,9 @@
use std::collections::{HashMap, HashSet};
use fxhash::FxHashSet;
use regex::Regex;
use serde::Serialize;
use crate::Error;
/// Minimal `direct_url.json` schema
///
/// <https://packaging.python.org/en/latest/specifications/direct-url/>
/// <https://www.python.org/dev/peps/pep-0610/>
#[derive(Serialize)]
struct DirectUrl {
#[allow(clippy::zero_sized_map_values)]
archive_info: HashMap<(), ()>,
url: String,
}
/// A script defining the name of the runnable entrypoint and the module and function that should be
/// run.
#[cfg(feature = "python_bindings")]
@ -57,12 +45,12 @@ impl Script {
.captures(value)
.ok_or_else(|| Error::InvalidWheel(format!("invalid console script: '{value}'")))?;
if let Some(script_extras) = captures.name("extras") {
let script_extras = script_extras
.as_str()
.split(',')
.map(|extra| extra.trim().to_string())
.collect::<HashSet<String>>();
if let Some(extras) = extras {
let script_extras = script_extras
.as_str()
.split(',')
.map(|extra| extra.trim().to_string())
.collect::<FxHashSet<String>>();
if !script_extras.is_subset(&extras.iter().cloned().collect()) {
return Ok(None);
}