Optimize mwscript access to global variables
To access (read or write) global variable in mwscript there is a set of instructions OpFetchGlobal*
and OpStoreGlobal*
. They take int index of a string literal from stack, find string literal from compiled program by index and use it to do a lookup in the MWWorld::World
global variables map. This is very slow. Here is typical profile of mwscript execution with !2600 (merged) applied: