Skip to content

Commit

Permalink
Fix repl optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
schungx committed Feb 17, 2024
1 parent 7cb0412 commit 54d1484
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Bug fixes
---------

* The position of an undefined operation call now points to the operator instead of the first operand.
* The `optimize` command in `rhai-repl` now works properly and cycles through `None`->`Simple`->`Full`.

Deprecated API's
----------------
Expand Down
22 changes: 14 additions & 8 deletions src/bin/rhai-repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,21 @@ fn main() {
continue;
}
#[cfg(not(feature = "no_optimize"))]
"optimize" if optimize_level == rhai::OptimizationLevel::Simple => {
optimize_level = rhai::OptimizationLevel::None;
println!("Script optimization turned OFF.");
continue;
}
#[cfg(not(feature = "no_optimize"))]
"optimize" => {
optimize_level = rhai::OptimizationLevel::Simple;
println!("Script optimization turned ON.");
match optimize_level {
rhai::OptimizationLevel::Full => {
optimize_level = rhai::OptimizationLevel::None;
println!("Script optimization turned OFF.");
}
rhai::OptimizationLevel::Simple => {
optimize_level = rhai::OptimizationLevel::Full;
println!("Script optimization turned to FULL.");
}
_ => {
optimize_level = rhai::OptimizationLevel::Simple;
println!("Script optimization turned to SIMPLE.");
}
}
continue;
}
"scope" => {
Expand Down

0 comments on commit 54d1484

Please sign in to comment.