#23721 [Opn]: TRUE and FALSE constants slower than keywords in previous versions
| From: | philip@php.net | Date: | Wed, 21 May 2003 16:14:51 +0000 |
| Subject: | #23721 [Opn]: TRUE and FALSE constants slower than keywords in previous versions | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969353718@lists.php.net to get a copy of this message | ||
ID: 23721
Updated by: philip@php.net
Reported By: max at fuck dot org
Status: Open
Bug Type: Documentation problem
Operating System: FreeBSD
PHP Version: 4.3.1
New Comment:
PHP groupees sometimes mention:
a) ++$i is faster than $i++
b) 'foo' is faster than "foo"
c) echo is faster than print
d) str_* is faster than regex
e) And now true is faster than TRUE!
Woohoo! My PHP scripts will be blazing fast!!! :)
Previous Comments:
------------------------------------------------------------------------
[2003-05-21 10:05:56] sniper@php.net
Code readability always outweights minor performance gains, IMO. :)
------------------------------------------------------------------------
[2003-05-21 08:57:42] max at fuck dot org
I don't think I would ever use true/false a million times. This came up
when talking to someone about which way was 'proper', whereas before it
didn't seem to make a difference and now to allow people who want to
write 'True' to get their way, it has been changed. While I don't think
this is a big performance problem or anything, I think in conjuction
with other little slow-downs on a high load site it could have an
effect on the speed. It's obviously faster than older versions
regardless of how you use it, but I don't think I have ever seen it
used in lowercase anywhere on the php website.
------------------------------------------------------------------------
[2003-05-21 03:11:08] derick@php.net
Why do you use 1000000 times TRUE or FALSE in your programs anyway?
------------------------------------------------------------------------
[2003-05-21 02:01:07] philip@php.net
Use of proper case is faster than "improper" case for case insensitive
constants. This includes true/false, null, and define()'s third
parameter. Not sure what others... or even if this really should be
documented? :) AFAICT, this behavior does not affect magical case
insensitive constants such as __file__.
This difference is as of 4.2.3
------------------------------------------------------------------------
[2003-05-20 20:08:24] sniper@php.net
In real life applications you really won't notice any difference. And
the lowercase version of any constant defined
as case-insensitive will always be looked up faster.
(ie. true is looked for first, then if not found, TRUE)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/23721
--
Edit this bug report at http://bugs.php.net/?id=23721&edit=1