Prefix can be case-insensitive, delegate to its Hash impl instead of trying to hash the raw bytes

This should have 0 performance overhead on unix since Prefix is always None.
This commit is contained in:
The8472 2021-11-11 21:42:59 +01:00
parent a6e0aa20d9
commit c1ea7bdc87
2 changed files with 9 additions and 0 deletions

View File

@ -2892,6 +2892,14 @@ impl cmp::PartialEq for Path {
impl Hash for Path {
fn hash<H: Hasher>(&self, h: &mut H) {
let bytes = self.as_u8_slice();
let prefix_len = match parse_prefix(&self.inner) {
Some(prefix) => {
prefix.hash(h);
prefix.len()
}
None => 0,
};
let bytes = &bytes[prefix_len..];
let mut component_start = 0;
let mut bytes_hashed = 0;

View File

@ -11,6 +11,7 @@ pub fn is_verbatim_sep(b: u8) -> bool {
b == b'/'
}
#[inline]
pub fn parse_prefix(_: &OsStr) -> Option<Prefix<'_>> {
None
}