Skip to content

Commit

Permalink
chore: always use new_unchecked (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Apr 7, 2024
1 parent 5baa6b3 commit 7f41c77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 3 additions & 5 deletions src/tracing/js/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,9 @@ impl OpObj {
let to_string = FunctionObjectBuilder::new(
context.realm(),
NativeFunction::from_copy_closure(move |_this, _args, _ctx| {
let op = OpCode::new(value).unwrap_or_else(|| {
// unknown opcode, this could be an additional opcode that is not part of the
// enum
unsafe { OpCode::new_unchecked(value) }
});
// we always want an OpCode, even it is unknown because it could be an additional
// opcode that not a known constant
let op = unsafe { OpCode::new_unchecked(value) };
let s = op.to_string();
Ok(JsValue::from(js_string!(s)))
}),
Expand Down
7 changes: 3 additions & 4 deletions src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,9 @@ impl TracingInspector {
None
};

let op = OpCode::new(interp.current_opcode()).unwrap_or_else(|| {
// unknown opcode, this could be an additional opcode that is not part of the enum
unsafe { OpCode::new_unchecked(interp.current_opcode()) }
});
// we always want an OpCode, even it is unknown because it could be an additional opcode
// that not a known constant
let op = unsafe { OpCode::new_unchecked(interp.current_opcode()) };

trace.trace.steps.push(CallTraceStep {
depth: context.journaled_state.depth(),
Expand Down

0 comments on commit 7f41c77

Please sign in to comment.