avm1: Avoid unnecessary calls to `search_prototype`
The signature of `search_prototype` is going to change in a following commit. Use `TObject::call_method` instead.
This commit is contained in:
parent
d0763607e2
commit
09f72b880d
|
@ -6,7 +6,6 @@
|
||||||
//!
|
//!
|
||||||
//! TODO: Could we use this for AVM2 timers as well?
|
//! TODO: Could we use this for AVM2 timers as well?
|
||||||
|
|
||||||
use crate::avm1::object::search_prototype;
|
|
||||||
use crate::avm1::{Activation, ActivationIdentifier, AvmString, Object, TObject, Value};
|
use crate::avm1::{Activation, ActivationIdentifier, AvmString, Object, TObject, Value};
|
||||||
use crate::context::UpdateContext;
|
use crate::context::UpdateContext;
|
||||||
use gc_arena::Collect;
|
use gc_arena::Collect;
|
||||||
|
@ -49,10 +48,6 @@ impl<'gc> Timers<'gc> {
|
||||||
level0,
|
level0,
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: `this` is undefined for non-method timer callbacks, but our VM
|
|
||||||
// currently doesn't allow `this` to be a Value (#843).
|
|
||||||
let undefined = Value::Undefined.coerce_to_object(&mut activation);
|
|
||||||
|
|
||||||
let mut tick_count = 0;
|
let mut tick_count = 0;
|
||||||
let cur_time = activation.context.timers.cur_time;
|
let cur_time = activation.context.timers.cur_time;
|
||||||
|
|
||||||
|
@ -88,33 +83,26 @@ impl<'gc> Timers<'gc> {
|
||||||
let params = timer.params.clone();
|
let params = timer.params.clone();
|
||||||
let callback = timer.callback.clone();
|
let callback = timer.callback.clone();
|
||||||
|
|
||||||
let callback = match callback {
|
match callback {
|
||||||
TimerCallback::Function(f) => Some((undefined, None, f)),
|
TimerCallback::Function(function) => {
|
||||||
TimerCallback::Method { this, method_name } => {
|
// TODO: `this` is undefined for non-method timer callbacks, but our VM
|
||||||
// Fetch the callback method from the object.
|
// currently doesn't allow `this` to be a Value (#843).
|
||||||
if let Ok((f, base_proto)) =
|
let this = Value::Undefined.coerce_to_object(&mut activation);
|
||||||
search_prototype(Value::Object(this), method_name, &mut activation, this)
|
let _ = function.call(
|
||||||
{
|
"[Timer Callback]".into(),
|
||||||
let f = f.coerce_to_object(&mut activation);
|
&mut activation,
|
||||||
Some((this, base_proto, f))
|
this,
|
||||||
} else {
|
None,
|
||||||
None
|
¶ms,
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
TimerCallback::Method { this, method_name } => {
|
||||||
|
let _ = this.call_method(method_name, ¶ms, &mut activation);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
if let Some((this, base_proto, function)) = callback {
|
|
||||||
let _ = function.call(
|
|
||||||
"[Timer Callback]".into(),
|
|
||||||
&mut activation,
|
|
||||||
this,
|
|
||||||
base_proto,
|
|
||||||
¶ms,
|
|
||||||
);
|
|
||||||
|
|
||||||
crate::player::Player::run_actions(&mut activation.context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
crate::player::Player::run_actions(&mut activation.context);
|
||||||
|
|
||||||
let mut timer = activation.context.timers.peek_mut().unwrap();
|
let mut timer = activation.context.timers.peek_mut().unwrap();
|
||||||
if timer.is_timeout {
|
if timer.is_timeout {
|
||||||
// Timeouts only fire once.
|
// Timeouts only fire once.
|
||||||
|
|
Loading…
Reference in New Issue