> On Sep 2, 2020, at 5:54 PM, Stanislav Malyshev <smalys...@gmail.com> wrote: > > Hi! > >>> In theory, this should be a general performance win any time one >>> needs to iterate over only the keys of an iterable, because it does >>> not require the use of an O(n) iteration and building of the array >>> that array_keys() would, plus it works on non-array types (such as >>> generators or iterators). It also is more performant than >>> foreach($iterable as $key => $_) {}, because it omits the opcode >>> that instructs the engine to retrieve the value. (Presumably, a >>> future direction could include using this request to inform >>> generators or > > To me, it looks like the case of premature micro-optimization. Unless > there's a benchmark that proves it achieves speedup in a real-life > application (not tight-loop synthetic benchmark) I think > foreach($iterable as $key => $_) {} is completely fine. My opinion has > been and remains, absent new data, that if your code performance hinges > on a couple of simple opcodes being there, maybe you'd better implement > that part in C, but in most real-life applications it is not and any > performance gain you might get from such syntax is microscopic.
If it adds a micro-optimization, great, but allowing a developer to explicitly signal intent is the primary argument for adding void. IMO. -Mike -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php