Re: [SMARTY-DEV] New plugin

From: Date: Wed, 28 May 2003 07:46:41 +0000
Subject: Re: [SMARTY-DEV] New plugin
References: 1 2 3 4 5 6  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1517@lists.php.net to get a copy of this message
On Tue, May 27, 2003 at 11:05:34PM +0100, Patrick Emond wrote: > I thought about dividing by powers of 2 but you'll notice in the plugin > that to speed up the calculation there isn't actually a division going :) > on - that and dividing by 1024 would suggest that we're working out > bytes and not any other unit (like scientific units for instance). Calculation are faster for numeric operations (I think binary >> is faster anyway). String operations like copying, cutting etc. are slower because memory operations are slower (in your plugin there are 3 division (%/) operations and two substr'ing). Because you check for intval() - you can never convert any number greater than 2147483647 (~ 2G). Function is_numeric() would be better in this case, altough not perfect (you can use also ereg("[^0-9]",$var)). Best regards, -- Piotr Klaban

« previous php.smarty.dev (#1517) next »