From 90a544a34a58718f963b51e6fa6b365681ec10b3 Mon Sep 17 00:00:00 2001 From: relrelb Date: Wed, 25 Aug 2021 01:55:47 +0300 Subject: [PATCH] avm1: Inline `SuperObject::super_constr` --- core/src/avm1/object/super_object.rs | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/core/src/avm1/object/super_object.rs b/core/src/avm1/object/super_object.rs index e2e0240ca..2ae852aa1 100644 --- a/core/src/avm1/object/super_object.rs +++ b/core/src/avm1/object/super_object.rs @@ -48,22 +48,6 @@ impl<'gc> SuperObject<'gc> { }, )) } - - /// Retrieve the constructor associated with the super proto. - fn super_constr( - self, - activation: &mut Activation<'_, 'gc, '_>, - ) -> Result>, Error<'gc>> { - if let Value::Object(super_proto) = self.proto(activation) { - Ok(Some( - super_proto - .get("__constructor__", activation)? - .coerce_to_object(activation), - )) - } else { - Ok(None) - } - } } impl<'gc> TObject<'gc> for SuperObject<'gc> { @@ -87,6 +71,7 @@ impl<'gc> TObject<'gc> for SuperObject<'gc> { //TODO: What happens if you set `super.__proto__`? Ok(()) } + fn call( &self, name: &str, @@ -95,12 +80,11 @@ impl<'gc> TObject<'gc> for SuperObject<'gc> { _base_proto: Option>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { - if let Some(constr) = self.super_constr(activation)? { - let super_proto = match self.proto(activation) { - Value::Object(o) => Some(o), - _ => None, - }; - constr.call(name, activation, self.0.read().child, super_proto, args) + if let Value::Object(proto) = self.proto(activation) { + let constructor = proto + .get("__constructor__", activation)? + .coerce_to_object(activation); + constructor.call(name, activation, self.0.read().child, Some(proto), args) } else { Ok(Value::Undefined) }