Use debug_assert.

This commit is contained in:
Stephen Chung
2023-03-23 09:12:48 +08:00
parent 2c94f956e5
commit 3c7cd8e278
7 changed files with 19 additions and 24 deletions

View File

@@ -397,9 +397,10 @@ impl Engine {
match lhs {
// id.??? or id[???]
Expr::Variable(.., var_pos) => {
self.track_operation(global, *var_pos)?;
#[cfg(feature = "debugging")]
self.run_debugger(global, caches, scope, this_ptr.as_deref_mut(), lhs)?;
self.track_operation(global, *var_pos)?;
let target = &mut self.search_namespace(global, caches, scope, this_ptr, lhs)?;

View File

@@ -236,8 +236,7 @@ impl Engine {
mut this_ptr: Option<&mut Dynamic>,
expr: &Expr,
) -> RhaiResult {
// Coded this way for better branch prediction.
// Popular branches are lifted out of the `match` statement into their own branches.
self.track_operation(global, expr.position())?;
#[cfg(feature = "debugging")]
let reset =
@@ -245,8 +244,6 @@ impl Engine {
#[cfg(feature = "debugging")]
auto_restore! { global if Some(reset) => move |g| g.debugger_mut().reset_status(reset) }
self.track_operation(global, expr.position())?;
match expr {
// Constants
Expr::IntegerConstant(x, ..) => Ok((*x).into()),

View File

@@ -267,14 +267,14 @@ impl Engine {
stmt: &Stmt,
rewind_scope: bool,
) -> RhaiResult {
self.track_operation(global, stmt.position())?;
#[cfg(feature = "debugging")]
let reset =
self.run_debugger_with_reset(global, caches, scope, this_ptr.as_deref_mut(), stmt)?;
#[cfg(feature = "debugging")]
auto_restore! { global if Some(reset) => move |g| g.debugger_mut().reset_status(reset) }
self.track_operation(global, stmt.position())?;
match stmt {
// No-op
Stmt::Noop(..) => Ok(Dynamic::UNIT),
@@ -307,6 +307,8 @@ impl Engine {
.eval_expr(global, caches, scope, this_ptr.as_deref_mut(), rhs)?
.flatten();
self.track_operation(global, lhs.position())?;
let mut target = self.search_namespace(global, caches, scope, this_ptr, lhs)?;
let is_temp_result = !target.is_ref();
@@ -326,8 +328,6 @@ impl Engine {
.into());
}
self.track_operation(global, lhs.position())?;
self.eval_op_assignment(global, caches, op_info, lhs, &mut target, rhs_val)?;
} else {
#[cfg(any(not(feature = "no_index"), not(feature = "no_object")))]
@@ -715,8 +715,6 @@ impl Engine {
*scope.get_mut_by_index(index).write_lock().unwrap() = value;
// Run block
self.track_operation(global, body.position())?;
if body.is_empty() {
continue;
}