Hi! A while ago webchick pointed out http://www.php.lt/benchmark/phpbench.php this site for me. The most striking difference is using in_array on a non-set variable. core has 118 in_array calls :) some wanna check them? Regards NK
Hi, Interesting page but I don't see anything on in_array(). I think you mean is_array()? Tim Karoly Negyesi wrote:
Hi!
A while ago webchick pointed out http://www.php.lt/benchmark/phpbench.php this site for me.
The most striking difference is using in_array on a non-set variable. core has 118 in_array calls :) some wanna check them?
Regards
NK
Tim Young wrote:
Hi,
Interesting page but I don't see anything on in_array(). I think you mean is_array()?
Tim
Karoly Negyesi wrote:
Hi!
A while ago webchick pointed out http://www.php.lt/benchmark/phpbench.php this site for me.
The most striking difference is using in_array on a non-set variable. core has 118 in_array calls :) some wanna check them?
I'll do it. ..chrisxj
Karoly Negyesi wrote:
A while ago webchick pointed out http://www.php.lt/benchmark/phpbench.php this site for me.
The most striking difference is using in_array on a non-set variable. core has 118 in_array calls :) some wanna check them?
How about we come to a consensus on the right way to treat these calls before I roll a patch against 31 core files. My first suggestion is this: 1. If the is_array() is checking something that might not be set, I change the code to say "isSet() && is_array()". 2. If the code is obviously checking something that will always be set, I leave it alone. Any other possibilities? Or should I just change them all to be like #1 to future-proof the code? ..chrisxj
This review / performance improvement is well under way. I've noticed that we could completely delete a lot of is_array() calls if we simply defined the argument as an array only. It is either an array, or it isn't. The caller should wrap the single element in array() if need be. What are other opinions? I'll fix them if we agree that's the right way to go. ..chrisxj
Interestingly, most of the is_array() calls that are *not* checking for for singleton versus array arguments appear to have been just added to handle the new Forms API coding using arrays. There is lots of code that looks like this: if (is_array($form[$module][$key]) ... I'm not sure what to make of it, but I thought it was interesting that the Forms API has resulted in lots of new is_array() calls. ..chrisxj
I agree that, whenever possible, a value's type should be known and assumed correct. Anything else is a bug. Of course, I also believe that a value's NULL status should always be known, and known to not be. :-) If we can ensure that possibly-NULL values get a standard false value (0 for ints, '' for strings) that makes achieving E_ALL compliance much easier, and the code much cleaner. (The only time isset() should be necessary is if the value being tested is a parameter to the same function where the isset() is, and when a non-NULL default value can't be used.) On Friday 09 December 2005 06:19 pm, Chris Johnson wrote:
This review / performance improvement is well under way.
I've noticed that we could completely delete a lot of is_array() calls if we simply defined the argument as an array only. It is either an array, or it isn't. The caller should wrap the single element in array() if need be.
What are other opinions?
I'll fix them if we agree that's the right way to go.
..chrisxj
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
Karoly Negyesi wrote:
Hi!
A while ago webchick pointed out http://www.php.lt/benchmark/phpbench.php this site for me.
The most striking difference is using in_array on a non-set variable. core has 118 in_array calls :) some wanna check them?
Regards
NK
Now issue #40631 http://drupal.org/node/40631 ..chrisxj
Patch available at http://drupal.org/node/40631
On Fri, Dec 09, 2005 at 08:08:49AM +0100, Karoly Negyesi wrote:
A while ago webchick pointed out http://www.php.lt/benchmark/phpbench.php this site for me.
BTW, another site about optimization: http://fetter.org/optimization.html ;) -- Piotrek irc: #debian.pl Mors Drosophilis melanogastribus!
participants (5)
-
Chris Johnson -
Karoly Negyesi -
Larry Garfield -
piotr@mallorn.ii.uj.edu.pl -
Tim Young