Move more &str to AsRef<str>
This commit is contained in:
parent
f49ff28b82
commit
d88e17d177
@ -62,7 +62,10 @@ 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 = &'a str>, var_name: &str) -> u64 {
|
||||
pub fn calc_qualified_var_hash<'a>(
|
||||
modules: impl Iterator<Item = impl AsRef<str> + 'a>,
|
||||
var_name: impl AsRef<str>,
|
||||
) -> u64 {
|
||||
let s = &mut get_hasher();
|
||||
|
||||
// We always skip the first module
|
||||
@ -70,9 +73,9 @@ pub fn calc_qualified_var_hash<'a>(modules: impl Iterator<Item = &'a str>, var_n
|
||||
modules
|
||||
.inspect(|_| len += 1)
|
||||
.skip(1)
|
||||
.for_each(|m| m.hash(s));
|
||||
.for_each(|m| m.as_ref().hash(s));
|
||||
len.hash(s);
|
||||
var_name.hash(s);
|
||||
var_name.as_ref().hash(s);
|
||||
s.finish()
|
||||
}
|
||||
|
||||
@ -87,8 +90,8 @@ pub fn calc_qualified_var_hash<'a>(modules: impl Iterator<Item = &'a str>, var_n
|
||||
/// The first module name is skipped. Hashing starts from the _second_ module in the chain.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn calc_qualified_fn_hash<'a>(
|
||||
modules: impl Iterator<Item = &'a str>,
|
||||
pub fn calc_qualified_fn_hash(
|
||||
modules: impl Iterator<Item = impl AsRef<str>>,
|
||||
fn_name: impl AsRef<str>,
|
||||
num: usize,
|
||||
) -> u64 {
|
||||
@ -99,7 +102,7 @@ pub fn calc_qualified_fn_hash<'a>(
|
||||
modules
|
||||
.inspect(|_| len += 1)
|
||||
.skip(1)
|
||||
.for_each(|m| m.hash(s));
|
||||
.for_each(|m| m.as_ref().hash(s));
|
||||
len.hash(s);
|
||||
fn_name.as_ref().hash(s);
|
||||
num.hash(s);
|
||||
@ -113,7 +116,7 @@ pub fn calc_qualified_fn_hash<'a>(
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn calc_fn_hash(fn_name: impl AsRef<str>, num: usize) -> u64 {
|
||||
calc_qualified_fn_hash(empty(), fn_name, num)
|
||||
calc_qualified_fn_hash(empty::<&str>(), fn_name, num)
|
||||
}
|
||||
|
||||
/// Calculate a [`u64`] hash key from a list of parameter types.
|
||||
|
@ -107,8 +107,8 @@ impl FuncInfo {
|
||||
///
|
||||
/// The first module name is skipped. Hashing starts from the _second_ module in the chain.
|
||||
#[inline]
|
||||
fn calc_native_fn_hash<'a>(
|
||||
modules: impl Iterator<Item = &'a str>,
|
||||
fn calc_native_fn_hash(
|
||||
modules: impl Iterator<Item = impl AsRef<str>>,
|
||||
fn_name: impl AsRef<str>,
|
||||
params: &[TypeId],
|
||||
) -> u64 {
|
||||
@ -711,7 +711,7 @@ impl Module {
|
||||
#[cfg(feature = "metadata")]
|
||||
param_names.shrink_to_fit();
|
||||
|
||||
let hash_fn = calc_native_fn_hash(empty(), name.as_ref(), ¶m_types);
|
||||
let hash_fn = calc_native_fn_hash(empty::<&str>(), name.as_ref(), ¶m_types);
|
||||
|
||||
self.functions.insert(
|
||||
hash_fn,
|
||||
|
@ -2269,7 +2269,7 @@ impl Engine {
|
||||
#[must_use]
|
||||
pub fn lex<'a>(
|
||||
&'a self,
|
||||
input: impl IntoIterator<Item = &'a &'a str>,
|
||||
input: impl IntoIterator<Item = &'a (AsRef<str> + 'a)>,
|
||||
) -> (TokenIterator<'a>, TokenizerControl) {
|
||||
self.lex_raw(input, None)
|
||||
}
|
||||
@ -2280,7 +2280,7 @@ impl Engine {
|
||||
#[must_use]
|
||||
pub fn lex_with_map<'a>(
|
||||
&'a self,
|
||||
input: impl IntoIterator<Item = &'a &'a str>,
|
||||
input: impl IntoIterator<Item = &'a (AsRef<str> + 'a)>,
|
||||
token_mapper: &'a OnParseTokenCallback,
|
||||
) -> (TokenIterator<'a>, TokenizerControl) {
|
||||
self.lex_raw(input, Some(token_mapper))
|
||||
|
Loading…
Reference in New Issue
Block a user