This repository has been archived on 2025-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
rhaj/rhai_engine/rhaibook/engine/optimize/disable.md
2025-04-19 08:10:30 +02:00

610 B

Turn Off Script Optimizations

{{#include ../../links.md}}

When scripts:

  • are known to be run only once and then thrown away,

  • are known to contain no dead code,

  • do not use constants in calculations

the optimization pass may be a waste of time and resources.

In that case, turn optimization off by setting the optimization level to [OptimizationLevel::None].

let engine = rhai::Engine::new();

// Turn off the optimizer
engine.set_optimization_level(rhai::OptimizationLevel::None);

Alternatively, disable optimizations via the [no_optimize] feature.