RE: ip-to-country - summary

From: Date: Fri, 02 May 2003 09:04:30 +0000
Subject: RE: ip-to-country - summary
References: 1  Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-17202@lists.php.net to get a copy of this message
> BTW I have modified the indexing code since I sent it to you > to write out the > granularity to the index too, so the script reading the file > will find a > self-contained data file with every detail needed to search > in the index. > Original: function i2c_ip2num($dotted) { $dotted = preg_split("/[.]+/", $dotted); return (float) ($dotted[0] * 16777216) + ($dotted[1] * 65536) + ($dotted[2] * 256) + ($dotted[3]); } Suggested Change: function i2c_ip2num($dotted) { $dotted = preg_split("/[.]+/", $dotted); return ($dotted[0] << 24) | ($dotted[1] << 16) | ($dotted[2] << 8) | $dotted[3]; } Since a multiplication takes 8 cpu cycles while a shift operator takes 2, this would give a slight boost. Havent got a chance to look at the search in greater detail. But since you have already worked on it and achieved real good speeds, it would not make sense to spend more time on it. - Div

« previous php.mirrors (#17202) next »