[php-src] Issue #10428: Function returning value by reference should return/create reference only if needed

From: Date: Tue, 24 Jan 2023 00:16:34 +0000
Subject: [php-src] Issue #10428: Function returning value by reference should return/create reference only if needed
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243549@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10428
Author: mvorisek

### Description

https://3v4l.org/npLfI

When assigning to a variable & must used to assign the value by reference.

Currently when a function returning a reference is called, it seems the optimizer is not smart
enough to detect the result will be used by value, and the reference is always created, which make
the call slower.

My usecase is heavily used public function &__get(string $name) {} method which
needs to be declared with & for rare purposes, but normally, the result is
assigned/used by value and I belive this can be optimized by php engine to make the performance the
same as if the method would be declared /wo &.

I know there were https://wiki.php.net/rfc/explicit_send_by_ref.
This feature request is solely to improve the performance /wo any language change.


Thread (1 message)

  • mvorisek
« previous php.bugs (#243549) next »