Do not inline error path functions.

This commit is contained in:
Stephen Chung 2021-10-19 20:16:36 +08:00
parent 2334cd8f56
commit 6d31bb0d19
5 changed files with 7 additions and 5 deletions

View File

@ -9,6 +9,7 @@ Enhancements
* `NativeCallContext::call_fn_dynamic_raw` is deprecated and `NativeCallContext::call_fn_raw` is added.
* Array methods now avoid cloning as much as possible (although most predicates will involve cloning anyway if passed a closure).
* Inlining is disabled for error-path functions because, most of the time, the script fails completely when an error is encountered.
Version 1.1.0

View File

@ -216,14 +216,14 @@ impl fmt::Display for EvalAltResult {
}
impl<T: AsRef<str>> From<T> for EvalAltResult {
#[inline(always)]
#[inline(never)]
fn from(err: T) -> Self {
Self::ErrorRuntime(err.as_ref().to_string().into(), Position::NONE)
}
}
impl<T: AsRef<str>> From<T> for Box<EvalAltResult> {
#[inline(always)]
#[inline(never)]
fn from(err: T) -> Self {
EvalAltResult::ErrorRuntime(err.as_ref().to_string().into(), Position::NONE).into()
}
@ -444,7 +444,7 @@ impl EvalAltResult {
}
/// Consume the current [`EvalAltResult`] and return a new one with the specified [`Position`]
/// if the current position is [`Position::None`].
#[inline]
#[inline(never)]
#[must_use]
pub(crate) fn fill_position(mut self: Box<Self>, new_position: Position) -> Box<Self> {
if self.position().is_none() {

View File

@ -266,7 +266,7 @@ impl fmt::Display for ParseErrorType {
}
impl From<LexError> for ParseErrorType {
#[inline(always)]
#[inline(never)]
fn from(err: LexError) -> Self {
match err {
LexError::StringTooLong(max) => {

View File

@ -481,6 +481,7 @@ impl Engine {
pos: Position,
level: usize,
) -> RhaiResult {
#[inline(never)]
fn make_error(
name: String,
fn_def: &crate::ast::ScriptFnDef,

View File

@ -9,7 +9,7 @@ use std::prelude::v1::*;
#[cfg(not(feature = "no_float"))]
use num_traits::Float;
#[inline(always)]
#[inline(never)]
pub fn make_err(msg: impl Into<String>) -> Box<EvalAltResult> {
EvalAltResult::ErrorArithmetic(msg.into(), Position::NONE).into()
}