Skip to content

Commit 54d1484

Browse files
committed
Fix repl optimization.
1 parent 7cb0412 commit 54d1484

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Bug fixes
88
---------
99

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

1213
Deprecated API's
1314
----------------

src/bin/rhai-repl.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,15 +438,21 @@ fn main() {
438438
continue;
439439
}
440440
#[cfg(not(feature = "no_optimize"))]
441-
"optimize" if optimize_level == rhai::OptimizationLevel::Simple => {
442-
optimize_level = rhai::OptimizationLevel::None;
443-
println!("Script optimization turned OFF.");
444-
continue;
445-
}
446-
#[cfg(not(feature = "no_optimize"))]
447441
"optimize" => {
448-
optimize_level = rhai::OptimizationLevel::Simple;
449-
println!("Script optimization turned ON.");
442+
match optimize_level {
443+
rhai::OptimizationLevel::Full => {
444+
optimize_level = rhai::OptimizationLevel::None;
445+
println!("Script optimization turned OFF.");
446+
}
447+
rhai::OptimizationLevel::Simple => {
448+
optimize_level = rhai::OptimizationLevel::Full;
449+
println!("Script optimization turned to FULL.");
450+
}
451+
_ => {
452+
optimize_level = rhai::OptimizationLevel::Simple;
453+
println!("Script optimization turned to SIMPLE.");
454+
}
455+
}
450456
continue;
451457
}
452458
"scope" => {

0 commit comments

Comments
 (0)