diff --git a/src/dynamic.rs b/src/dynamic.rs index 193280a7..3354e2bf 100644 --- a/src/dynamic.rs +++ b/src/dynamic.rs @@ -420,7 +420,7 @@ impl Hash for Dynamic { } /// Map the name of a standard type into a friendly form. -#[inline] +#[inline(always)] pub(crate) fn map_std_type_name(name: &str) -> &str { if name == type_name::() { "string" @@ -1496,7 +1496,7 @@ impl Dynamic { } /// Convert the [`Dynamic`] into an [`ImmutableString`] and return it. /// Returns the name of the actual type if the cast fails. - #[inline] + #[inline(always)] pub fn take_immutable_string(self) -> Result { match self.0 { Union::Str(s, _) => Ok(s), diff --git a/src/engine.rs b/src/engine.rs index 7f562742..e8ac7b90 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -862,7 +862,7 @@ impl Engine { /// Create a new [`Engine`] with minimal built-in functions. /// /// Use [`register_global_module`][Engine::register_global_module] to add packages of functions. - #[inline] + #[inline(always)] pub fn new_raw() -> Self { Self { global_namespace: Default::default(), diff --git a/src/engine_api.rs b/src/engine_api.rs index ee804636..9ac38a97 100644 --- a/src/engine_api.rs +++ b/src/engine_api.rs @@ -1034,7 +1034,6 @@ impl Engine { /// Read the contents of a file into a string. #[cfg(not(feature = "no_std"))] #[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))] - #[inline] fn read_file(path: crate::stdlib::path::PathBuf) -> Result> { use crate::stdlib::io::Read; @@ -1276,7 +1275,7 @@ impl Engine { /// # Ok(()) /// # } /// ``` - #[inline] + #[inline(always)] pub fn compile_expression_with_scope( &self, scope: &Scope, @@ -1385,7 +1384,7 @@ impl Engine { /// # Ok(()) /// # } /// ``` - #[inline] + #[inline(always)] pub fn eval_with_scope( &self, scope: &mut Scope, @@ -1437,7 +1436,7 @@ impl Engine { /// # Ok(()) /// # } /// ``` - #[inline] + #[inline(always)] pub fn eval_expression_with_scope( &self, scope: &mut Scope, @@ -1502,7 +1501,7 @@ impl Engine { /// # Ok(()) /// # } /// ``` - #[inline] + #[inline(always)] pub fn eval_ast_with_scope( &self, scope: &mut Scope, @@ -1578,7 +1577,7 @@ impl Engine { } /// Evaluate a string with own scope, but throw away the result and only return error (if any). /// Useful for when you don't need the result, but still need to keep track of possible errors. - #[inline] + #[inline(always)] pub fn consume_with_scope( &self, scope: &mut Scope, @@ -1659,7 +1658,7 @@ impl Engine { /// # } /// ``` #[cfg(not(feature = "no_function"))] - #[inline] + #[inline(always)] pub fn call_fn( &self, scope: &mut Scope, @@ -1760,7 +1759,7 @@ impl Engine { /// Do not use the arguments after this call. If they are needed afterwards, /// clone them _before_ calling this function. #[cfg(not(feature = "no_function"))] - #[inline] + #[inline(always)] pub(crate) fn call_fn_dynamic_raw( &self, scope: &mut Scope, @@ -1814,7 +1813,7 @@ impl Engine { /// (i.e. with [`Scope::push_constant`]). /// Then, the [`AST`] is cloned and the copy re-optimized before running. #[cfg(not(feature = "no_optimize"))] - #[inline] + #[inline(always)] pub fn optimize_ast( &self, scope: &Scope, diff --git a/src/fn_call.rs b/src/fn_call.rs index a9e4c009..18d11447 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -176,7 +176,7 @@ impl Engine { /// 3) Global modules - packages /// 4) Imported modules - functions marked with global namespace /// 5) Global sub-modules - functions marked with global namespace - #[inline] + #[inline(always)] fn resolve_function<'s>( &self, mods: &Imports, @@ -831,7 +831,7 @@ impl Engine { /// Evaluate a list of statements with no `this` pointer. /// This is commonly used to evaluate a list of statements in an [`AST`] or a script function body. - #[inline] + #[inline(always)] pub(crate) fn eval_global_statements( &self, scope: &mut Scope, diff --git a/src/fn_register.rs b/src/fn_register.rs index bba1e46d..48ed4bab 100644 --- a/src/fn_register.rs +++ b/src/fn_register.rs @@ -183,7 +183,7 @@ macro_rules! def_register { RET: Variant + Clone > RegisterFn for Engine { - #[inline] + #[inline(always)] fn register_fn(&mut self, name: &str, f: FN) -> &mut Self { self.global_namespace.set_fn(name, FnNamespace::Global, FnAccess::Public, None, &[$(map_type_id::<$par>()),*], @@ -198,7 +198,7 @@ macro_rules! def_register { FN: Fn($($param),*) -> RhaiResult + SendSync + 'static, > RegisterResultFn for Engine { - #[inline] + #[inline(always)] fn register_result_fn(&mut self, name: &str, f: FN) -> &mut Self { self.global_namespace.set_fn(name, FnNamespace::Global, FnAccess::Public, None, &[$(map_type_id::<$par>()),*], diff --git a/src/module/mod.rs b/src/module/mod.rs index 695f8565..0c3a0041 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -598,7 +598,7 @@ impl Module { /// let hash = module.set_fn_0("calc", || Ok(42_i64)); /// assert!(module.contains_fn(hash, true)); /// ``` - #[inline] + #[inline(always)] pub fn contains_fn(&self, hash_fn: NonZeroU64, public_only: bool) -> bool { if public_only { self.functions diff --git a/src/parser.rs b/src/parser.rs index bfef0a54..96e1da4e 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -105,7 +105,7 @@ impl<'e> ParseState<'e> { /// i.e. the top element of the [`ParseState`] is offset 1. /// /// Return `None` when the variable name is not found in the `stack`. - #[inline] + #[inline(always)] fn access_var(&mut self, name: &str, _pos: Position) -> Option { let mut barrier = false; @@ -230,7 +230,7 @@ impl Expr { /// Convert a [`Variable`][Expr::Variable] into a [`Property`][Expr::Property]. /// All other variants are untouched. #[cfg(not(feature = "no_object"))] - #[inline] + #[inline(always)] fn into_property(self, state: &mut ParseState) -> Self { match self { Self::Variable(x) if x.1.is_none() => { diff --git a/src/scope.rs b/src/scope.rs index 4adda3e1..2071a75d 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -237,7 +237,7 @@ impl<'a> Scope<'a> { self.push_dynamic_value(name, AccessMode::ReadOnly, value) } /// Add (push) a new entry with a [`Dynamic`] value to the [`Scope`]. - #[inline] + #[inline(always)] pub(crate) fn push_dynamic_value( &mut self, name: impl Into>, @@ -420,7 +420,7 @@ impl<'a> Scope<'a> { } /// Clone the [`Scope`], keeping only the last instances of each variable name. /// Shadowed variables are omitted in the copy. - #[inline] + #[inline(always)] pub(crate) fn clone_visible(&self) -> Self { let mut entries: Self = Default::default(); diff --git a/src/token.rs b/src/token.rs index 31c87f30..5cd1cc5c 100644 --- a/src/token.rs +++ b/src/token.rs @@ -1029,7 +1029,7 @@ fn scan_block_comment( /// # Volatile API /// /// This function is volatile and may change. -#[inline] +#[inline(always)] pub fn get_next_token( stream: &mut impl InputStream, state: &mut TokenizeState, @@ -1856,7 +1856,7 @@ impl Engine { self.lex_raw(input, Some(map)) } /// Tokenize an input text stream with an optional mapping function. - #[inline] + #[inline(always)] pub(crate) fn lex_raw<'a>( &'a self, input: impl IntoIterator, diff --git a/src/unsafe.rs b/src/unsafe.rs index 2cef9997..772eb35a 100644 --- a/src/unsafe.rs +++ b/src/unsafe.rs @@ -49,7 +49,7 @@ pub fn unsafe_cast_box(item: Box) -> Result, B /// /// Force-casting a local variable's lifetime to the current [`Scope`][crate::Scope]'s larger lifetime saves /// on allocations and string cloning, thus avoids us having to maintain a chain of [`Scope`][crate::Scope]'s. -#[inline] +#[inline(always)] pub fn unsafe_cast_var_name_to_lifetime<'s>(name: &str) -> &'s str { // WARNING - force-cast the variable name into the scope's lifetime to avoid cloning it // this is safe because all local variables are cleared at the end of the block