It's not "just as valid", you dolt. My way is better.
function sperglord(%obj)
{
// 5 runs of 100,000 iterations
for(%a = 0; %a < 5; %a++)
{
%startTime = getRealTime();
for(%b = 0; %b < 100000; %b++)
{
if(%obj.getClassName() $= "AIPlayer" || %obj.getClassName() $= "Player")
{
}
}
echo("\"function sperglord\" Runtime Cycle " @ %a @ ":" SPC (getRealTime() - %startTime) @ "ms");
}
}
function better(%obj)
{
// 5 runs of 100,000 iterations
for(%a = 0; %a < 5; %a++)
{
%startTime = getRealTime();
for(%b = 0; %b < 100000; %b++)
{
if(%obj.getType() & $TypeMasks::PlayerObjectType)
{
}
}
echo("\"function better\" Runtime Cycle " @ %a @ ":" SPC (getRealTime() - %startTime) @ "ms");
}
}
==>sperglord(findClientByName("Frontier").player);
"function sperglord" Runtime Cycle 0: 64ms
"function sperglord" Runtime Cycle 1: 62ms
"function sperglord" Runtime Cycle 2: 60ms
"function sperglord" Runtime Cycle 3: 59ms
"function sperglord" Runtime Cycle 4: 57ms
==>better(findClientByName("Frontier").player);
"function better" Runtime Cycle 0: 24ms
"function better" Runtime Cycle 1: 24ms
"function better" Runtime Cycle 2: 23ms
"function better" Runtime Cycle 3: 22ms
"function better" Runtime Cycle 4: 21ms
I don't know what sort of high you get off challenging what I've said, but you're wrong. You've completely lost this. Your way is almost three times slower than mine, and the more class names you add to that if statement the slower it goes.