Got a question that the wiki doesn't answer? Ask on the forum (preferred), or join us on IRC.

About the ads

CommandHelper/Optimizer

From SK's Wiki
Jump to: navigation, search

Because CommandHelper is a compiled language, it is able to add in optimizations that most scripting languages cannot. Take for example, the following code: (2 + 2) * 8 There is in fact no reason this can't be completely replaced with 32. There is no case where this will not equal 32, so we can simply replace this at compile time, essentially, run the code at compile time. However, the code (2 + @x) * 8 cannot be simplified, without knowing the value of @x. So, CommandHelper takes this into consideration, and automatically optimizes in cases where it is possible. The most relevant places is in the math functions, and the string handling functions. Concatenation happens at compile time now as well, which happens quite often. Consider the simple alias: /cmd = /another command. In previous versions, this would actually be a script that was run each time, with the full overhead of invoking the sconcat function. However, there is no reason we can't turn this into a single string at compile time, and not have to deal with the overhead later, each time the function is run.

Another thing to note, is that static include()s will now also compile and cache at compile time. Previously even if you had simple compile errors in the included file, they wouldn't be caught until runtime. This is no longer the case. They will be compiled and optimized at the same time as the script currently being compiled.





Namespaces

Variants
Actions