It's better to use a directly-indexed array (i.e. $::my_array(my_index) ) than to use switch or matchclass (again, assuming your data doesn't need to be dynamic); (this is likely because matchclass requires calling a function, and includes additional matching features that cost CPU cycles)
It's better to use a command like [HTTP::uri] than to place the value in a variable (tested up to 20 re-uses, it did not seem to be converging -- variables appear to always be more expensive). (this is likely due optimization which caches the result of commands in case they are re-used)
The amount of code in an unused switch statement or an un-called if block doesn't seem to be a performance consideration. Only worry about what code is executed.
It's better to use "switch" than any form of "if", whenever possible (likely due to the added expression evaluation in "if")
It's better to use chained "if"/"elseif" statements than to use separate "if" statements (likely due to "if"/"elseif" being a single statement so fewer commands are lookup up and run, and fewer return values must be considered).
It's better to use "switch" (even with -glob) instead of "matchclass" for comparisons of 100 elements or less (and of course only if your data does not need to be dynamic); (this is likely due to matchclass using md5 as it's hash)
文章评论