Fixup AsRef<str> vs &str.

This commit is contained in:
Stephen Chung
2022-01-04 15:22:48 +08:00
parent 1d1e473ac4
commit d99953c101
13 changed files with 181 additions and 181 deletions

View File

@@ -87,10 +87,7 @@ pub fn get_hasher() -> ahash::AHasher {
/// The first module name is skipped. Hashing starts from the _second_ module in the chain.
#[inline]
#[must_use]
pub fn calc_qualified_var_hash<'a>(
modules: impl Iterator<Item = impl AsRef<str> + 'a>,
var_name: impl AsRef<str>,
) -> u64 {
pub fn calc_qualified_var_hash<'a>(modules: impl Iterator<Item = &'a str>, var_name: &str) -> u64 {
let s = &mut get_hasher();
// We always skip the first module
@@ -98,9 +95,9 @@ pub fn calc_qualified_var_hash<'a>(
modules
.inspect(|_| len += 1)
.skip(1)
.for_each(|m| m.as_ref().hash(s));
.for_each(|m| m.hash(s));
len.hash(s);
var_name.as_ref().hash(s);
var_name.hash(s);
match s.finish() {
0 => ALT_ZERO_HASH,
@@ -123,9 +120,9 @@ pub fn calc_qualified_var_hash<'a>(
/// The first module name is skipped. Hashing starts from the _second_ module in the chain.
#[inline]
#[must_use]
pub fn calc_qualified_fn_hash(
modules: impl Iterator<Item = impl AsRef<str>>,
fn_name: impl AsRef<str>,
pub fn calc_qualified_fn_hash<'a>(
modules: impl Iterator<Item = &'a str>,
fn_name: &str,
num: usize,
) -> u64 {
let s = &mut get_hasher();
@@ -135,9 +132,9 @@ pub fn calc_qualified_fn_hash(
modules
.inspect(|_| len += 1)
.skip(1)
.for_each(|m| m.as_ref().hash(s));
.for_each(|m| m.hash(s));
len.hash(s);
fn_name.as_ref().hash(s);
fn_name.hash(s);
num.hash(s);
match s.finish() {
@@ -156,8 +153,8 @@ pub fn calc_qualified_fn_hash(
/// If the hash happens to be zero, it is mapped to `DEFAULT_HASH`.
#[inline(always)]
#[must_use]
pub fn calc_fn_hash(fn_name: impl AsRef<str>, num: usize) -> u64 {
calc_qualified_fn_hash(empty::<&str>(), fn_name, num)
pub fn calc_fn_hash(fn_name: &str, num: usize) -> u64 {
calc_qualified_fn_hash(empty(), fn_name, num)
}
/// Calculate a non-zero [`u64`] hash key from a list of parameter types.