From 3610b5eb7e996a5d05cec966cd4445cfbe98be0e Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sat, 14 Aug 2021 15:10:37 +0800 Subject: [PATCH] Change some inline(always) into inline. --- src/custom_syntax.rs | 2 +- src/dynamic.rs | 32 ++++++++++++++++---------------- src/engine.rs | 16 ++++++++-------- src/engine_api.rs | 8 ++++---- src/error.rs | 2 +- src/fn_register.rs | 2 +- src/module/mod.rs | 8 ++++---- src/parse.rs | 6 +++--- src/scope.rs | 16 ++++++++-------- 9 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/custom_syntax.rs b/src/custom_syntax.rs index e77bee10..6e98eee1 100644 --- a/src/custom_syntax.rs +++ b/src/custom_syntax.rs @@ -81,7 +81,7 @@ impl Expression<'_> { /// [`ImmutableString`][crate::ImmutableString]. /// /// Returns [`None`] also if the constant is not of the specified type. - #[inline(always)] + #[inline] #[must_use] pub fn get_literal_value(&self) -> Option { // Coded this way in order to maximally leverage potentials for dead-code removal. diff --git a/src/dynamic.rs b/src/dynamic.rs index 8441a940..401e3907 100644 --- a/src/dynamic.rs +++ b/src/dynamic.rs @@ -1038,7 +1038,7 @@ impl Dynamic { /// assert_eq!(new_result.type_name(), "string"); /// assert_eq!(new_result.to_string(), "hello"); /// ``` - #[inline(always)] + #[inline] #[must_use] pub fn from(mut value: T) -> Self { // Coded this way in order to maximally leverage potentials for dead-code removal. @@ -1179,7 +1179,7 @@ impl Dynamic { /// /// assert_eq!(x.try_cast::().unwrap(), 42); /// ``` - #[inline(always)] + #[inline] #[must_use] pub fn try_cast(self) -> Option { // Coded this way in order to maximally leverage potentials for dead-code removal. @@ -1538,7 +1538,7 @@ impl Dynamic { /// Casting to [`Dynamic`] just returns a reference to it. /// /// Returns [`None`] if the cast fails, or if the value is shared. - #[inline(always)] + #[inline] #[must_use] pub(crate) fn downcast_ref(&self) -> Option<&T> { // Coded this way in order to maximally leverage potentials for dead-code removal. @@ -1629,7 +1629,7 @@ impl Dynamic { /// Casting to [`Dynamic`] just returns a mutable reference to it. /// /// Returns [`None`] if the cast fails, or if the value is shared. - #[inline(always)] + #[inline] #[must_use] pub(crate) fn downcast_mut(&mut self) -> Option<&mut T> { // Coded this way in order to maximally leverage potentials for dead-code removal. @@ -1728,7 +1728,7 @@ impl Dynamic { } /// Cast the [`Dynamic`] as a unit `()` and return it. /// Returns the name of the actual type if the cast fails. - #[inline(always)] + #[inline] pub fn as_unit(&self) -> Result<(), &'static str> { match self.0 { Union::Unit(value, _, _) => Ok(value), @@ -1739,7 +1739,7 @@ impl Dynamic { } /// Cast the [`Dynamic`] as the system integer type [`INT`] and return it. /// Returns the name of the actual type if the cast fails. - #[inline(always)] + #[inline] pub fn as_int(&self) -> Result { match self.0 { Union::Int(n, _, _) => Ok(n), @@ -1753,7 +1753,7 @@ impl Dynamic { /// /// Not available under `no_float`. #[cfg(not(feature = "no_float"))] - #[inline(always)] + #[inline] pub fn as_float(&self) -> Result { match self.0 { Union::Float(n, _, _) => Ok(*n), @@ -1767,7 +1767,7 @@ impl Dynamic { /// /// Exported under the `decimal` feature only. #[cfg(feature = "decimal")] - #[inline(always)] + #[inline] pub fn as_decimal(&self) -> Result { match self.0 { Union::Decimal(ref n, _, _) => Ok(**n), @@ -1778,7 +1778,7 @@ impl Dynamic { } /// Cast the [`Dynamic`] as a [`bool`] and return it. /// Returns the name of the actual type if the cast fails. - #[inline(always)] + #[inline] pub fn as_bool(&self) -> Result { match self.0 { Union::Bool(b, _, _) => Ok(b), @@ -1789,7 +1789,7 @@ impl Dynamic { } /// Cast the [`Dynamic`] as a [`char`] and return it. /// Returns the name of the actual type if the cast fails. - #[inline(always)] + #[inline] pub fn as_char(&self) -> Result { match self.0 { Union::Char(n, _, _) => Ok(n), @@ -1804,7 +1804,7 @@ impl Dynamic { /// # Panics /// /// Panics if the value is shared. - #[inline(always)] + #[inline] pub(crate) fn as_str_ref(&self) -> Result<&str, &'static str> { match self.0 { Union::Str(ref s, _, _) => Ok(s), @@ -1816,7 +1816,7 @@ impl Dynamic { /// Convert the [`Dynamic`] into a [`String`] and return it. /// If there are other references to the same string, a cloned copy is returned. /// Returns the name of the actual type if the cast fails. - #[inline(always)] + #[inline] pub fn as_string(self) -> Result { self.as_immutable_string().map(ImmutableString::into_owned) } @@ -1954,7 +1954,7 @@ impl Dynamic { impl, T: Variant + Clone> From> for Dynamic { - #[inline(always)] + #[inline] fn from(value: std::collections::HashMap) -> Self { Self(Union::Map( Box::new( @@ -1971,7 +1971,7 @@ impl, T: Variant + Clone> From> From> for Dynamic { - #[inline(always)] + #[inline] fn from(value: std::collections::HashSet) -> Self { Self(Union::Map( Box::new( @@ -1989,7 +1989,7 @@ impl> From> for Dynamic impl, T: Variant + Clone> From> for Dynamic { - #[inline(always)] + #[inline] fn from(value: std::collections::BTreeMap) -> Self { Self(Union::Map( Box::new( @@ -2005,7 +2005,7 @@ impl, T: Variant + Clone> From> From> for Dynamic { - #[inline(always)] + #[inline] fn from(value: std::collections::BTreeSet) -> Self { Self(Union::Map( Box::new( diff --git a/src/engine.rs b/src/engine.rs index 95dbf331..8d9df163 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -98,7 +98,7 @@ impl Imports { self.modules.get_mut(index) } /// Get the index of an imported [module][Module] by name. - #[inline(always)] + #[inline] #[must_use] pub fn find(&self, name: &str) -> Option { self.keys @@ -121,7 +121,7 @@ impl Imports { } /// Get an iterator to this stack of imported [modules][Module] in reverse order. #[allow(dead_code)] - #[inline(always)] + #[inline] pub fn iter(&self) -> impl Iterator { self.keys .iter() @@ -131,13 +131,13 @@ impl Imports { } /// Get an iterator to this stack of imported [modules][Module] in reverse order. #[allow(dead_code)] - #[inline(always)] + #[inline] pub(crate) fn iter_raw(&self) -> impl Iterator)> { self.keys.iter().rev().zip(self.modules.iter().rev()) } /// Get an iterator to this stack of imported [modules][Module] in forward order. #[allow(dead_code)] - #[inline(always)] + #[inline] pub(crate) fn scan_raw(&self) -> impl Iterator)> { self.keys.iter().zip(self.modules.iter()) } @@ -149,7 +149,7 @@ impl Imports { self.modules.iter().any(|m| m.contains_qualified_fn(hash)) } /// Get the specified function via its hash key from this stack of imported [modules][Module]. - #[inline(always)] + #[inline] #[must_use] pub fn get_fn(&self, hash: u64) -> Option<(&CallableFunction, Option<&Identifier>)> { self.modules @@ -167,7 +167,7 @@ impl Imports { } /// Get the specified [`TypeId`][std::any::TypeId] iterator from this stack of imported /// [modules][Module]. - #[inline(always)] + #[inline] #[must_use] pub fn get_iter(&self, id: TypeId) -> Option { self.modules @@ -182,7 +182,7 @@ impl IntoIterator for Imports { type IntoIter = Zip>, Rev; 4]>>>; - #[inline(always)] + #[inline] fn into_iter(self) -> Self::IntoIter { self.keys .into_iter() @@ -694,7 +694,7 @@ impl EvalState { self.scope_level == 0 } /// Get a mutable reference to the current function resolution cache. - #[inline(always)] + #[inline] #[must_use] pub fn fn_resolution_cache_mut(&mut self) -> &mut FnResolutionCache { if self.fn_resolution_caches.is_empty() { diff --git a/src/engine_api.rs b/src/engine_api.rs index 99213283..9b29a6ba 100644 --- a/src/engine_api.rs +++ b/src/engine_api.rs @@ -574,7 +574,7 @@ impl Engine { /// # } /// ``` #[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] - #[inline(always)] + #[inline] pub fn register_indexer_get( &mut self, get_fn: impl Fn(&mut T, X) -> V + SendSync + 'static, @@ -648,7 +648,7 @@ impl Engine { /// # } /// ``` #[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] - #[inline(always)] + #[inline] pub fn register_indexer_get_result< T: Variant + Clone, X: Variant + Clone, @@ -724,7 +724,7 @@ impl Engine { /// # } /// ``` #[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] - #[inline(always)] + #[inline] pub fn register_indexer_set( &mut self, set_fn: impl Fn(&mut T, X, V) + SendSync + 'static, @@ -799,7 +799,7 @@ impl Engine { /// # } /// ``` #[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] - #[inline(always)] + #[inline] pub fn register_indexer_set_result< T: Variant + Clone, X: Variant + Clone, diff --git a/src/error.rs b/src/error.rs index acdb4499..270bfacd 100644 --- a/src/error.rs +++ b/src/error.rs @@ -447,7 +447,7 @@ impl EvalAltResult { } /// Consume the current [`EvalAltResult`] and return a new one with the specified [`Position`] /// if the current position is [`Position::None`]. - #[inline(always)] + #[inline] #[must_use] pub(crate) fn fill_position(mut self: Box, new_position: Position) -> Box { if self.position().is_none() { diff --git a/src/fn_register.rs b/src/fn_register.rs index cb90c62e..57a4e34f 100644 --- a/src/fn_register.rs +++ b/src/fn_register.rs @@ -39,7 +39,7 @@ pub fn by_ref(data: &mut Dynamic) -> DynamicWriteLock { } /// Dereference into value. -#[inline(always)] +#[inline] #[must_use] pub fn by_value(data: &mut Dynamic) -> T { if TypeId::of::() == TypeId::of::<&str>() { diff --git a/src/module/mod.rs b/src/module/mod.rs index c9d10706..3e80a579 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -455,7 +455,7 @@ impl Module { /// Get a reference to a namespace-qualified variable. /// Name and Position in [`EvalAltResult`] are [`None`] and [`NONE`][Position::NONE] and must be set afterwards. - #[inline(always)] + #[inline] pub(crate) fn get_qualified_var(&self, hash_var: u64) -> Result<&Dynamic, Box> { self.all_variables.get(&hash_var).ok_or_else(|| { EvalAltResult::ErrorVariableNotFound(String::new(), Position::NONE).into() @@ -497,7 +497,7 @@ impl Module { /// Get a shared reference to the script-defined function in the [`Module`] based on name /// and number of parameters. #[cfg(not(feature = "no_function"))] - #[inline(always)] + #[inline] #[must_use] pub fn get_script_fn( &self, @@ -965,7 +965,7 @@ impl Module { /// assert!(module.contains_fn(hash)); /// ``` #[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] - #[inline(always)] + #[inline] pub fn set_indexer_get_fn(&mut self, func: F) -> u64 where A: Variant + Clone, @@ -1026,7 +1026,7 @@ impl Module { /// assert!(module.contains_fn(hash)); /// ``` #[cfg(any(not(feature = "no_index"), not(feature = "no_object")))] - #[inline(always)] + #[inline] pub fn set_indexer_set_fn(&mut self, func: F) -> u64 where A: Variant + Clone, diff --git a/src/parse.rs b/src/parse.rs index 4b132653..7162081d 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -189,7 +189,7 @@ impl<'e> ParseState<'e> { /// /// Panics when called under `no_module`. #[cfg(not(feature = "no_module"))] - #[inline(always)] + #[inline] #[must_use] pub fn find_module(&self, name: &str) -> Option { self.modules @@ -325,7 +325,7 @@ impl Expr { } /// Make sure that the next expression is not a statement expression (i.e. wrapped in `{}`). -#[inline(always)] +#[inline] fn ensure_not_statement_expr(input: &mut TokenStream, type_name: &str) -> Result<(), ParseError> { match input.peek().expect(NEVER_ENDS) { (Token::LeftBrace, pos) => Err(PERR::ExprExpected(type_name.to_string()).into_err(*pos)), @@ -334,7 +334,7 @@ fn ensure_not_statement_expr(input: &mut TokenStream, type_name: &str) -> Result } /// Make sure that the next expression is not a mis-typed assignment (i.e. `a = b` instead of `a == b`). -#[inline(always)] +#[inline] fn ensure_not_assignment(input: &mut TokenStream) -> Result<(), ParseError> { match input.peek().expect(NEVER_ENDS) { (Token::Equals, pos) => Err(LexError::ImproperSymbol( diff --git a/src/scope.rs b/src/scope.rs index bd99207a..823d640d 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -63,7 +63,7 @@ impl<'a> IntoIterator for Scope<'a> { type Item = (Cow<'a, str>, Dynamic); type IntoIter = Box + 'a>; - #[inline(always)] + #[inline] fn into_iter(self) -> Self::IntoIter { Box::new( self.values @@ -293,7 +293,7 @@ impl<'a> Scope<'a> { /// assert!(my_scope.contains("x")); /// assert!(!my_scope.contains("y")); /// ``` - #[inline(always)] + #[inline] #[must_use] pub fn contains(&self, name: &str) -> bool { self.names @@ -302,7 +302,7 @@ impl<'a> Scope<'a> { .any(|(key, _)| name == key.as_ref()) } /// Find an entry in the [`Scope`], starting from the last. - #[inline(always)] + #[inline] #[must_use] pub(crate) fn get_index(&self, name: &str) -> Option<(usize, AccessMode)> { self.names @@ -329,7 +329,7 @@ impl<'a> Scope<'a> { /// my_scope.push("x", 42_i64); /// assert_eq!(my_scope.get_value::("x").unwrap(), 42); /// ``` - #[inline(always)] + #[inline] #[must_use] pub fn get_value(&self, name: &str) -> Option { self.names @@ -398,7 +398,7 @@ impl<'a> Scope<'a> { /// /// assert_eq!(my_scope.get_value::("x").unwrap(), 123); /// ``` - #[inline(always)] + #[inline] #[must_use] pub fn get_mut(&mut self, name: &str) -> Option<&mut Dynamic> { self.get_index(name) @@ -444,7 +444,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(always)] + #[inline] #[must_use] pub(crate) fn clone_visible(&self) -> Self { let mut entries = Self::new(); @@ -463,7 +463,7 @@ impl<'a> Scope<'a> { entries } /// Get an iterator to entries in the [`Scope`]. - #[inline(always)] + #[inline] #[allow(dead_code)] pub(crate) fn into_iter( self, @@ -507,7 +507,7 @@ impl<'a> Scope<'a> { } /// Get an iterator to entries in the [`Scope`]. /// Shared values are not expanded. - #[inline(always)] + #[inline] pub fn iter_raw(&self) -> impl Iterator { self.names .iter()