我正在尝试清理 PAC 文件。以下哪个代码块更简洁和/或更快?
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";}
相对
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";
我假设如果目标主机确实是“localhost”,那么第一个会更快,因为它会立即返回并且不需要评估剩余的条件。但是假设没有一个条件为真,那么首选哪种方法?