Add #[cold] tags.

This commit is contained in:
Stephen Chung
2022-09-13 22:54:13 +08:00
parent 2458e05dcb
commit 396ec7df8a
8 changed files with 43 additions and 17 deletions

View File

@@ -170,11 +170,8 @@ impl Engine {
keyword: impl AsRef<str>,
precedence: u8,
) -> Result<&mut Self, String> {
let precedence = Precedence::new(precedence);
if precedence.is_none() {
return Err("precedence cannot be zero".into());
}
let precedence =
Precedence::new(precedence).ok_or_else(|| "precedence cannot be zero".to_string())?;
let keyword = keyword.as_ref();
@@ -213,7 +210,8 @@ impl Engine {
}
// Add to custom keywords
self.custom_keywords.insert(keyword.into(), precedence);
self.custom_keywords
.insert(keyword.into(), Some(precedence));
Ok(self)
}

View File

@@ -238,6 +238,7 @@ impl Engine {
}
/// Make a `Box<`[`EvalAltResult<ErrorMismatchDataType>`][ERR::ErrorMismatchDataType]`>`.
#[cold]
#[inline(never)]
#[must_use]
pub(crate) fn make_type_mismatch_err<T>(&self, typ: &str, pos: Position) -> RhaiError {