Re: [SMARTY] new plugin: mailto

From: Date: Wed, 22 May 2002 01:54:32 +0000
Subject: Re: [SMARTY] new plugin: mailto
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4347@lists.php.net to get a copy of this message
This works, and after doing some simple tests the results are almost exactly 50% faster no matter how big the array is. Seeing this kind of improvement, I took a quick look at the Smarty code base. Almost every for loop recounts on each iteration. It looks like there is room for noticable improvement with a simple change to each loop (?) This would definately be a good idea for the compiled templates. The exception to the rule is if the variable being counted is altered during the loop. This is probably rare in the Smarty code, but must be examined for. Monte Alan McFarlane wrote:
or (untested) for ($i = 0, $j = count($mail_params); $i < $j; $i++) { //... } -- Alan McFarlane amcfarlane@bigfoot.com -----Original Message----- From: Kelly Cochran [mailto:kcochran@trolans.net] Sent: 22 May 2002 00:04 To: Smarty General Subject: Re: [SMARTY] new plugin: mailto Why not something like: if(count($mail_parms)) { $address .= '?' . implode('&', $mail_parms); } Then there's now the only one call to count() as well as ditching the now extraneous incrementer. Steve wrote: Just a minor performance note here: in this code snippet for ($i=0; $i<count($mail_parms); $i++) { $mail_parm_vals .= (0==$i) ? '?' : '&'; $mail_parm_vals .= $mail_parms[$i]; } count() is called once for each loop iteration. Obviously in this context that is only a couple of times. But in larger loops, this can become expensive. Another way to do it would be to call count once, assign the value and put the value in the for loop expression. -- - Kelly Cochran - (KC543) e-mail: kcochran@trolans.net WWW: http://www.trolans.net/


« previous php.smarty.general (#4347) next »