Re: [RFC] [Discussion] array_str_contains() for PHP 8.7
| From: | Kamil Tekiela | Date: | Mon, 31 Aug 2026 15:51:49 +0000 |
| Subject: | Re: [RFC] [Discussion] array_str_contains() for PHP 8.7 | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-132405@lists.php.net to get a copy of this message | ||
> 1. Short-circuiting vs Allocation: Using
array_filter processes
> the entire array and allocates a new filtered array in memory, whereas a dedicated C implementation
> (array_str_contains / short-circuit loop) immediately returns
> true on the first match without extra allocations.
What do you mean? I thought the purpose of the new function was to
return a list with all matching entries? How could it short-circuit on
the first match?
> 2. Direct C-level loop: Bypassing the VM dispatch loop for each element gives noticeable gains,
> especially on larger datasets or hot paths.
What kind of dispatch are you talking about here? Do you mean calling
str_contains() for each row?