Quoting Wade Preston Shearer <[EMAIL PROTECTED]>:
If one had a long page of functions (~50) that a script selected only one from, which would be faster to use: a switch, an if/else combination, or a variable function call?
The direct answer, from a cpu standpoint, is the switch is faster than the conditional, because the evaluating value is already passed in.
My concern is the first part of your statement. If the 50 functions are almost identical, lots of repeated code, I'd make a new function to replace them and make better use of input parameters. 100 lines of good code usually outperform 5000.
If they are wildly different, and your script only uses a few of the 50 functions, consider moving the functions to another file, and adjust input parameters, unless I was sharing some library file of functions with lots of other people. If it needs all 50, creating a function that works as a traffic cop, then ok. But I'd really wonder why I wasn't calling each function I needed directly.
-- Cole _______________________________________________ UPHPU mailing list [email protected] http://uphpu.org/mailman/listinfo/uphpu IRC: #uphpu on irc.freenode.net
