# Optimization when extensions don't provide handlers

- Thread: https://externals.io/message/129796
- Original archive: https://news-web.php.net/php.internals/129796
- Started by Barel on 2026-01-20T14:28:12+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #129796 — Barel — 2026-01-20T14:28:12+00:00

URL: https://externals.io/message/129796#129796

Hi

I have seen that the php-src uses some flags
like ZEND_EXTENSIONS_HAVE_OP_ARRAY_HANDLER to optimise the code so that the
loop that calls the op array handler is not called if no extension has set
up an op array handler

I wonder why this has not been done for
the statement_handler, fcall_begin_handler and fcall_end_handler. This
could be used to provide an optimised execution when no extension sets up a
handler for these extension points

Interested to know if there is a technical reason for this

Cheers

Carlos

---

## #129797 — Barel — 2026-01-20T17:27:00+00:00

URL: https://externals.io/message/129796#129797 · In reply to: #129796

> Hi
>
> I have seen that the php-src uses some flags
> like ZEND_EXTENSIONS_HAVE_OP_ARRAY_HANDLER to optimise the code so that the
> loop that calls the op array handler is not called if no extension has set
> up an op array handler
>
> I wonder why this has not been done for
> the statement_handler, fcall_begin_handler and fcall_end_handler. This
> could be used to provide an optimised execution when no extension sets up a
> handler for these extension points
>
> Interested to know if there is a technical reason for this
>
> Cheers
>
> Carlos
>

OK, I reply to myself. I can see that these handlers are only called if the
corresponding opcodes are compiled and these are only compiled
if  ZEND_COMPILE_EXTENDED_STMT or ZEND_COMPILE_EXTENDED_FCALL are set. So
an extension that does not set these handlers would not set these compiler
flags, then there is no need to do any more optimization :-)
