diff --git a/Cargo.toml b/Cargo.toml index 7eb97fb9..308685bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ num-traits = "*" [features] #default = ["no_function", "no_index", "no_float", "only_i32", "no_stdlib", "unchecked", "no_optimize"] -default = [] +default = [ "optimize_full" ] debug_msgs = [] # print debug messages on function registrations and calls unchecked = [] # unchecked arithmetic no_stdlib = [] # no standard library of utility functions @@ -27,6 +27,7 @@ no_index = [] # no arrays and indexing no_float = [] # no floating-point no_function = [] # no script-defined functions no_optimize = [] # no script optimizer +optimize_full = [] # set optimization level to Full (default is Simple) only_i32 = [] # set INT=i32 (useful for 32-bit systems) only_i64 = [] # set INT=i64 (default) and disable support for all other integer types diff --git a/src/engine.rs b/src/engine.rs index 6b951d4e..bee73cff 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -99,14 +99,20 @@ impl Engine<'_> { // Create the new scripting Engine let mut engine = Engine { - #[cfg(not(feature = "no_optimize"))] - optimization_level: OptimizationLevel::Full, ext_functions: HashMap::new(), script_functions: Vec::new(), type_iterators: HashMap::new(), type_names, on_print: Box::new(default_print), // default print/debug implementations on_debug: Box::new(default_print), + + #[cfg(not(feature = "no_optimize"))] + #[cfg(not(feature = "optimize_full"))] + optimization_level: OptimizationLevel::Simple, + + #[cfg(not(feature = "no_optimize"))] + #[cfg(feature = "optimize_full")] + optimization_level: OptimizationLevel::Full, }; engine.register_core_lib();