I'm trying to clean up a PAC file. Which of the following code blocks are more concise and/or faster?
if (host == "localhost") {return "DIRECT";}
if (shExpMatch(host, "localhost.*")) {return "DIRECT";}
if (host == "127.0.0.1") {return "DIRECT";}
if (isPlainHostName(host)) {return "DIRECT";}
if (isInNet(hostIP, "10.0.0.0", "255.0.0.0")) {return "DIRECT";}
versus
if ( host == "localhost" ||
host == "127.0.0.1" ||
shExpMatch( host, "localhost.*" ) ||
isPlainHostName( host ) ||
isInNet( hostIP, "10.0.0.0", "255.0.0.0" ))
return "DIRECT";
I'm assuming that if the target host is indeed "localhost," then the first would be faster, as it would hit the return right away and not need to evaluate the remaining conditionals. But assuming none of the conditions are true, which method is preferred?