avm2: Slightly improve findprop optimizations when property is found on script
This commit is contained in:
parent
b523ad4b32
commit
6acfc3953a
|
@ -850,15 +850,9 @@ pub fn optimize<'gc>(
|
||||||
// is unlikely to cause any real problems with SWFs.
|
// is unlikely to cause any real problems with SWFs.
|
||||||
*op = Op::GetScriptGlobals { script };
|
*op = Op::GetScriptGlobals { script };
|
||||||
|
|
||||||
let script_globals = script.globals_if_init();
|
if script.traits_loaded() {
|
||||||
|
|
||||||
if let Some(script_globals) = script_globals {
|
|
||||||
stack_push_done = true;
|
stack_push_done = true;
|
||||||
if let Some(global_class) = script_globals.instance_of() {
|
stack.push_class(script.global_class());
|
||||||
stack.push_class_object(global_class);
|
|
||||||
} else {
|
|
||||||
stack.push_any();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -585,6 +585,10 @@ impl<'gc> Script<'gc> {
|
||||||
self.0.read().translation_unit
|
self.0.read().translation_unit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn traits_loaded(self) -> bool {
|
||||||
|
self.0.read().traits_loaded
|
||||||
|
}
|
||||||
|
|
||||||
pub fn global_class(self) -> Class<'gc> {
|
pub fn global_class(self) -> Class<'gc> {
|
||||||
self.0
|
self.0
|
||||||
.read()
|
.read()
|
||||||
|
@ -636,19 +640,6 @@ impl<'gc> Script<'gc> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the global scope for the script.
|
|
||||||
///
|
|
||||||
/// If the script has not yet been initialized, this will return None.
|
|
||||||
pub fn globals_if_init(&self) -> Option<Object<'gc>> {
|
|
||||||
let read = self.0.read();
|
|
||||||
|
|
||||||
if !read.initialized {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(read.globals)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return traits for this script.
|
/// Return traits for this script.
|
||||||
///
|
///
|
||||||
/// This function will return an error if it is incorrectly called before
|
/// This function will return an error if it is incorrectly called before
|
||||||
|
|
Loading…
Reference in New Issue