Re: Suggestion to zend-api: some lookahead could make functions calls faster!

From: Date: Tue, 16 Nov 1999 04:58:33 +0000
Subject: Re: Suggestion to zend-api: some lookahead could make functions calls faster!
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-6278@lists.php.net to get a copy of this message
At 07:33 PM 11/15/99 +0100, Thies C. Arntzen wrote:
hi, just an idea: if a c-function knew the the returned value will be discarded by the caller (the script) there would be no need to set up return_value. reset() for example returns a copy of the 1st array element. i never use that... reset($arr); // no need to copy 1st array element into return_value $first = reset($arr); // set up return_value
This sounds like a pretty good idea. I'll try and take the time to implement this.
even smarter libzend could pass a flag to a c-function telling that the return-value will just be used as a bool: $a = key($array); // key() needs to create the return_value completely if (key($array)) // resturn_value could just be true/false { }
Forget it :)
i'd also like a new set of first(), current(), next() etc functions that return a reference to the corresponding array element instead of a copy - something like r_first() would be ugly - how about &first()?
You can't use &first as a function name. I don't like the first(), current(), next() syntax (it only exists for PHP/FI 2 compatibility). I think having something like each() or foreach() that works with references is more feasible. Andi --- Andi Gutmans <andi@zend.com> http://www.zend.com/

« previous php.version4 (#6278) next »