Re: [PEPr] +1 for XML::XML_Feed_Parser
| From: | Sean Coates | Date: | Fri, 21 Oct 2005 01:02:54 +0000 |
| Subject: | Re: [PEPr] +1 for XML::XML_Feed_Parser | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-40238@lists.php.net to get a copy of this message | ||
Sorry to jump in...
> JP> I would prefer using ' for all strings except those with
> JP> backslash expressions as variable interpolation is more expensive
> JP> and less visible than concatenation.
Justin, are you sure? I always understood concatenation to be slower
because memory had to be allocated separately for each string (prior to
concatenation) whereas with interpolation, the memory is already
allocated. Not trying to start a fight--I actually want to know your
interpretation/proof.
> JP> Please use ++$var instead of $var++ unless you must use a
> JP> post ++. Prepending it is slightly more efficient and is less
> JP> prone to error.
>
> Very convincing. Do you have some grounds to study?
This is a well-known optimization trick. George explains it very well in
his book. The gist is that there is no unique left operand when using
++$var; In $var++, the pre- and post-increment values both need to be
captured, so ++$var is faster (IIRC)
S