Move restore up one level.
This commit is contained in:
parent
2c55c248fb
commit
397b5eb39d
@ -26,8 +26,8 @@ Deprecated API's
|
||||
Speed improvements
|
||||
------------------
|
||||
|
||||
* The functions registration mechanism is revamped to take advantage of constant generics, among others.
|
||||
* This yields a 10-20% speed improvements on certain real-life, function-call-heavy workloads.
|
||||
* The function registration mechanism is revamped to take advantage of constant generics, among others, to omit checking code where possible. This yields a 10-20% speed improvements on certain real-life, function-call-heavy workloads.
|
||||
* Functions taking function pointers as parameters, usually called with closures, now run faster because a link to the anonymous function (generated by the closure) is stored together with the function pointer itself. This allows short-circuiting the function lookup step.
|
||||
|
||||
Net features
|
||||
------------
|
||||
|
27
src/lib.rs
27
src/lib.rs
@ -88,6 +88,8 @@ use std::prelude::v1::*;
|
||||
#[macro_use]
|
||||
mod reify;
|
||||
#[macro_use]
|
||||
mod restore;
|
||||
#[macro_use]
|
||||
mod types;
|
||||
|
||||
mod api;
|
||||
@ -100,6 +102,8 @@ mod module;
|
||||
mod optimizer;
|
||||
pub mod packages;
|
||||
mod parser;
|
||||
#[cfg(feature = "serde")]
|
||||
pub mod serde;
|
||||
mod tests;
|
||||
mod tokenizer;
|
||||
|
||||
@ -201,6 +205,8 @@ type InclusiveRange = std::ops::RangeInclusive<INT>;
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub use api::build_type::{CustomType, TypeBuilder};
|
||||
#[cfg(not(feature = "no_custom_syntax"))]
|
||||
pub use api::custom_syntax::Expression;
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
pub use api::files::{eval_file, run_file};
|
||||
@ -208,18 +214,18 @@ pub use api::{eval::eval, events::VarDefInfo, run::run};
|
||||
pub use ast::{FnAccess, AST};
|
||||
pub use engine::{Engine, OP_CONTAINS, OP_EQUALS};
|
||||
pub use eval::EvalContext;
|
||||
pub use func::{NativeCallContext, RegisterNativeFunction};
|
||||
use func::{calc_fn_hash, calc_fn_hash_full, calc_var_hash};
|
||||
pub use func::{plugin, FuncArgs, NativeCallContext, RegisterNativeFunction};
|
||||
pub use module::{FnNamespace, Module};
|
||||
use restore::RestoreOnDrop;
|
||||
pub use rhai_codegen::*;
|
||||
#[cfg(not(feature = "no_time"))]
|
||||
pub use types::Instant;
|
||||
pub use types::Position;
|
||||
pub use types::{
|
||||
Dynamic, EvalAltResult, FnPtr, ImmutableString, LexError, ParseError, ParseErrorType, Scope,
|
||||
Dynamic, EvalAltResult, FnPtr, ImmutableString, LexError, ParseError, ParseErrorType, Position,
|
||||
Scope,
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "no_custom_syntax"))]
|
||||
pub use api::custom_syntax::Expression;
|
||||
|
||||
/// _(debugging)_ Module containing types for debugging.
|
||||
/// Exported under the `debugging` feature only.
|
||||
#[cfg(feature = "debugging")]
|
||||
@ -245,15 +251,9 @@ pub use func::Shared;
|
||||
/// Alias to [`RefCell`][std::cell::RefCell] or [`RwLock`][std::sync::RwLock] depending on the `sync` feature flag.
|
||||
pub use func::Locked;
|
||||
|
||||
use func::{calc_fn_hash, calc_fn_hash_full, calc_var_hash};
|
||||
|
||||
/// A shared [`Module`].
|
||||
type SharedModule = Shared<Module>;
|
||||
|
||||
pub use rhai_codegen::*;
|
||||
|
||||
pub use func::{plugin, FuncArgs};
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
pub use func::Func;
|
||||
|
||||
@ -294,9 +294,6 @@ pub use module::ModuleResolver;
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
pub use module::resolvers as module_resolvers;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
pub mod serde;
|
||||
|
||||
#[cfg(not(feature = "no_optimize"))]
|
||||
pub use optimizer::OptimizationLevel;
|
||||
|
||||
|
@ -34,7 +34,7 @@ macro_rules! auto_restore {
|
||||
auto_restore!($var = $var => $restore);
|
||||
};
|
||||
($var:ident = $value:expr => $restore:expr) => {
|
||||
let $var = &mut *crate::types::RestoreOnDrop::lock($value, $restore);
|
||||
let $var = &mut *crate::RestoreOnDrop::lock($value, $restore);
|
||||
};
|
||||
($var:ident if Some($guard:ident) => $restore:expr) => {
|
||||
auto_restore!($var = ($var) if Some($guard) => $restore);
|
||||
@ -42,7 +42,7 @@ macro_rules! auto_restore {
|
||||
($var:ident = ( $value:expr ) if Some($guard:ident) => $restore:expr) => {
|
||||
let mut __rx__;
|
||||
let $var = if let Some($guard) = $guard {
|
||||
__rx__ = crate::types::RestoreOnDrop::lock($value, $restore);
|
||||
__rx__ = crate::RestoreOnDrop::lock($value, $restore);
|
||||
&mut *__rx__
|
||||
} else {
|
||||
&mut *$value
|
||||
@ -54,7 +54,7 @@ macro_rules! auto_restore {
|
||||
($var:ident = ( $value:expr ) if $guard:expr => $restore:expr) => {
|
||||
let mut __rx__;
|
||||
let $var = if $guard {
|
||||
__rx__ = crate::types::RestoreOnDrop::lock($value, $restore);
|
||||
__rx__ = crate::RestoreOnDrop::lock($value, $restore);
|
||||
&mut *__rx__
|
||||
} else {
|
||||
&mut *$value
|
@ -1,8 +1,5 @@
|
||||
//! Module defining Rhai data types.
|
||||
|
||||
#[macro_use]
|
||||
pub mod restore;
|
||||
|
||||
pub mod bloom_filter;
|
||||
pub mod custom_types;
|
||||
pub mod dynamic;
|
||||
@ -35,6 +32,5 @@ pub use position::{Position, Span};
|
||||
#[cfg(feature = "no_position")]
|
||||
pub use position_none::{Position, Span};
|
||||
|
||||
pub use restore::RestoreOnDrop;
|
||||
pub use scope::Scope;
|
||||
pub use variant::Variant;
|
||||
|
Loading…
Reference in New Issue
Block a user