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.
|
/// The first module name is skipped. Hashing starts from the _second_ module in the chain.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[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();
|
let s = &mut get_hasher();
|
||||||
|
|
||||||
// We always skip the first module
|
// 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
|
modules
|
||||||
.inspect(|_| len += 1)
|
.inspect(|_| len += 1)
|
||||||
.skip(1)
|
.skip(1)
|
||||||
.for_each(|m| m.hash(s));
|
.for_each(|m| m.as_ref().hash(s));
|
||||||
len.hash(s);
|
len.hash(s);
|
||||||
var_name.hash(s);
|
var_name.as_ref().hash(s);
|
||||||
s.finish()
|
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.
|
/// The first module name is skipped. Hashing starts from the _second_ module in the chain.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn calc_qualified_fn_hash<'a>(
|
pub fn calc_qualified_fn_hash(
|
||||||
modules: impl Iterator<Item = &'a str>,
|
modules: impl Iterator<Item = impl AsRef<str>>,
|
||||||
fn_name: impl AsRef<str>,
|
fn_name: impl AsRef<str>,
|
||||||
num: usize,
|
num: usize,
|
||||||
) -> u64 {
|
) -> u64 {
|
||||||
@ -99,7 +102,7 @@ pub fn calc_qualified_fn_hash<'a>(
|
|||||||
modules
|
modules
|
||||||
.inspect(|_| len += 1)
|
.inspect(|_| len += 1)
|
||||||
.skip(1)
|
.skip(1)
|
||||||
.for_each(|m| m.hash(s));
|
.for_each(|m| m.as_ref().hash(s));
|
||||||
len.hash(s);
|
len.hash(s);
|
||||||
fn_name.as_ref().hash(s);
|
fn_name.as_ref().hash(s);
|
||||||
num.hash(s);
|
num.hash(s);
|
||||||
@ -113,7 +116,7 @@ pub fn calc_qualified_fn_hash<'a>(
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn calc_fn_hash(fn_name: impl AsRef<str>, num: usize) -> u64 {
|
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.
|
/// 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.
|
/// The first module name is skipped. Hashing starts from the _second_ module in the chain.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn calc_native_fn_hash<'a>(
|
fn calc_native_fn_hash(
|
||||||
modules: impl Iterator<Item = &'a str>,
|
modules: impl Iterator<Item = impl AsRef<str>>,
|
||||||
fn_name: impl AsRef<str>,
|
fn_name: impl AsRef<str>,
|
||||||
params: &[TypeId],
|
params: &[TypeId],
|
||||||
) -> u64 {
|
) -> u64 {
|
||||||
@ -711,7 +711,7 @@ impl Module {
|
|||||||
#[cfg(feature = "metadata")]
|
#[cfg(feature = "metadata")]
|
||||||
param_names.shrink_to_fit();
|
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(
|
self.functions.insert(
|
||||||
hash_fn,
|
hash_fn,
|
||||||
|
@ -2269,7 +2269,7 @@ impl Engine {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn lex<'a>(
|
pub fn lex<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
input: impl IntoIterator<Item = &'a &'a str>,
|
input: impl IntoIterator<Item = &'a (AsRef<str> + 'a)>,
|
||||||
) -> (TokenIterator<'a>, TokenizerControl) {
|
) -> (TokenIterator<'a>, TokenizerControl) {
|
||||||
self.lex_raw(input, None)
|
self.lex_raw(input, None)
|
||||||
}
|
}
|
||||||
@ -2280,7 +2280,7 @@ impl Engine {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn lex_with_map<'a>(
|
pub fn lex_with_map<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
input: impl IntoIterator<Item = &'a &'a str>,
|
input: impl IntoIterator<Item = &'a (AsRef<str> + 'a)>,
|
||||||
token_mapper: &'a OnParseTokenCallback,
|
token_mapper: &'a OnParseTokenCallback,
|
||||||
) -> (TokenIterator<'a>, TokenizerControl) {
|
) -> (TokenIterator<'a>, TokenizerControl) {
|
||||||
self.lex_raw(input, Some(token_mapper))
|
self.lex_raw(input, Some(token_mapper))
|
||||||
|
Loading…
Reference in New Issue
Block a user