Add Rhai book.
This commit is contained in:
24
doc/src/engine/optimize/optimize-levels.md
Normal file
24
doc/src/engine/optimize/optimize-levels.md
Normal file
@@ -0,0 +1,24 @@
|
||||
Optimization Levels
|
||||
==================
|
||||
|
||||
{{#include ../../links.md}}
|
||||
|
||||
Set Optimization Level
|
||||
---------------------
|
||||
|
||||
There are actually three levels of optimizations: `None`, `Simple` and `Full`.
|
||||
|
||||
* `None` is obvious - no optimization on the AST is performed.
|
||||
|
||||
* `Simple` (default) performs only relatively _safe_ optimizations without causing side-effects
|
||||
(i.e. it only relies on static analysis and will not actually perform any function calls).
|
||||
|
||||
* `Full` is _much_ more aggressive, _including_ running functions on constant arguments to determine their result.
|
||||
One benefit to this is that many more optimization opportunities arise, especially with regards to comparison operators.
|
||||
|
||||
An [`Engine`]'s optimization level is set via a call to `Engine::set_optimization_level`:
|
||||
|
||||
```rust
|
||||
// Turn on aggressive optimizations
|
||||
engine.set_optimization_level(rhai::OptimizationLevel::Full);
|
||||
```
|
Reference in New Issue
Block a user