henesua wrote...
I suspect the additional overhead of the ExecuteScript call is negligible.
There is more overhead then one would originaly think. But I also do not think it is enough to worry too much about.
Two minor points things:
(1) I think it is more efficient to call GetModule() once and assign it to an object variable, than to call it many times. Its minor, but you were asking about overhead...
I myself do not know which one would be faster, It is nip-tuck on this one. Since it sounds like the script is already running on the module OBJECT_SELF would be the fastest.
(2) I believe ExecuteScript pauses all other execution until it is complete. Or at least pauses the current script execution until it is complete.
i would not really call this a pause, Anymore then I would concider calling a function as pausing the script. After all that is really all a script is, a special function that has a little more setup code to it. Right,
void main() {}
is really nothing more then a header for a void returning function called main.
ExecuteScript ( sName, oObject) ;
Can hypothetically be looked at as running the main function in another NameSpace. imagine 'void main' as having a prameter of OBJECT_SELF. ie. void main ( object OBJECT_SELF) { //Code block}
you could then hypothetically look at:
ExecuteScript ( "MyScript" , GetModule()) ;
being the same thing as:
MyScript.main(GetModule());
Where MyScript is the NameSpace that the Function 'main' is in and passing the module for OBJECT_SELF.
And two more that are more interesting:
(3) Depending on the particular scripts you are running from the main hook, you can likely find common ground between them, and increase both efficiency and effectiveness by rewriting them all to work together, share data etc... in a single script.
(4) Parceling out code into different executable chunks protects you from having too many "labels" (meaning two many identified variables, constants, function names etc....) all in one script which is not a small consideration if you are not using Virusman's and Skywing's hacks to the toolset and compiler.
Both points are excellent.
...
@Pstemarie: If your hooked scripts need to change the object they are running on. I would just leave them as scripts. If they are called by more then one script, I would still most likely leave them as scripts.
ahh, I really see no problem with leaving them as hooked scripts.
However if you did want to add all of the code into a single script, it does not really take any complex rewriting/ merging of the code. All you need to do is give the main function a new name, Then either Paste the function in the original script or just #include it. You can then just use a standard function call instead of the ExecuteScript.
Modifié par Lightfoot8, 14 août 2012 - 06:04 .