Re: using ($test)?$true:$false in a string
| From: | Robert Cummings | Date: | Mon, 21 Nov 2005 19:23:44 +0000 |
| Subject: | Re: using ($test)?$true:$false in a string | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-226234@lists.php.net to get a copy of this message | ||
On Mon, 2005-11-21 at 10:31, Richard Heyes wrote:
> Robert Cummings wrote:
> > On Mon, 2005-11-21 at 10:02, Richard Heyes wrote:
> >
> >>Readability is in the eye of the beholder.
> >
> >
> > But efficiency isn't ;)
>
> Try measuring the difference between the various methods over a
> realistic number of iterations, eg. 100. There's little point in going
> through ones code trying to "optimise" these things. Sure you might gain
> a millisecond here or there, but so what? You'd have to have a
> *seriously* busy site for that to make a difference.
I won't disagree, but I'd say being in the habit of writing semi-optimal
code in the fist place, will save you needing to learn new habits later
when you do work on a *seriously* busy site :) I didn't argue for ''
versus "", but sprintf() is a cycle pig in comparison to either. not
only that, but since it's not a keyword, it incurs stack overhead.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'