Re: [PHP4BETA] getParametersEx again - lets make PHP4 faster....
| From: | Zeev Suraski | Date: | Wed, 15 Sep 1999 23:14:05 +0000 |
| Subject: | Re: [PHP4BETA] getParametersEx again - lets make PHP4 faster.... | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-4500@lists.php.net to get a copy of this message | ||
At 16:42 15/09/1999 , Thies C. Arntzen wrote:
zeev, right now we would have to add a *lot* of SEPARATE_ZVAL into the current modules, so that if somebody calls a function by reference it won't change the parameters. $i_am_an_int = 1; echo strlen(&$i_am_an_int); will output "1" *AND* convert $i_am_an_int to a string! so we'd have to insert a SEPARATE_ZVAL in the strlen function. i believe that it would be worthwise to rethink this and come up with something better and more efficient. right now SEPARATE_ZVAL i needed 'cause we use first_arg_allow (& friends) to make things faster by default for certain functions - we couln't do it for sizeof() 'cause sizeof("hallo") is valid / sizeof(&"hallo") is NOT - on the other hand that means that sizeof($largearray) will be *FAR* slower that sizeof(&$largearray) - but why should a scripter always use call-by-reference? so - why not start to change module-by-module to the new getParametersEx API before PHP4b3? - i believe the speed impact will be noticed!I can't say I follow you exactly (could be the fact I'm dead tired), but I'll summarize: 1. We mustn't use first_arg_force_ref in any function that doesn't actually REQUIRE its arguments by reference. When a function requires its arguments by reference, any changes made to the by-ref'd variable are supposed to be reflected in the outside world as well, and indeed, we mustn't call SEPARATE_ZVAL(). 2. first_arg_allow_ref is meaningless in PHP 4.0 - there's no special optimization for function that may take their arguments by reference (there's no need to because of the reference counting mechanism). 3. The macros I suggested (convert_to_long_ex(), etc.) give you almost a braindead way of converting getParameters() to getParametersEx(). They're a bit more complicated then the way I sketched them since they need to take care of by-ref'd arguments, but other than that - they can be transparent replacements. 4. The macros I suggested can be optimized to some extent not to use copy_ctor and then convert, but immediately convert (for instance, when converting a string to a long, instead of copying the string and then converting it to a long, it would immediately convert the original string into the target long). That can be done at a later stage though, since it involves writing fair chunks of code. 5. I don't think the speed difference will be noticeable in anything other than benchmarks. We already know very well that the measured difference in benchmarks is very high (we've tested it with strlen() and beat Perl hands down). 6. That said, gradually moving stuff to the new API is a Good Thing (tm), but please wait until we actually have that API ready :) I didn't have time to put into it, but I'll try to do it this weekend! Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.il