Re: Add get_mangled_object_properties()
| From: | Nikita Popov | Date: | Tue, 14 May 2019 14:42:26 +0000 |
| Subject: | Re: Add get_mangled_object_properties() | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-105703@lists.php.net to get a copy of this message | ||
On Tue, May 14, 2019 at 4:29 PM Benjamin Morel <benjamin.morel@gmail.com>
wrote:
> I like the explicitness of the proposal, but only if performance is as
> good as (array) cast. One of the reasons we use casting to array in
> libraries is not only to access all properties at once, but also because
> it's fast as it's implemented as an opcode and not a function call. Would
> this function come with its own opcode, like strlen() / gettype() / etc.?
>
> Ben
>
I don't think an opcode is worthwhile in this case, because the primary
cost is in constructing the property array. On this micro-benchmark
https://gist.github.com/nikic/f592686c75d8d34d82ddc5900b598199
the results
are:
array cast: float(0.39156699180603)
get_mangled_object_vars(): float(0.41520500183105)
So no relevant difference in performance.
Nikita