#110990Reduce trimExplode processing and allocations
Description
Unlimited calls removing empty values filter the exploded array,
reindex it and then trim the retained values in a second pass. Calls
retaining empty values also split the entire string before folding the
tail to enforce a positive limit.
Trim and collect nonempty values in one loop for unlimited calls. Use
explode’s native positive limit when empty values are retained,
avoiding the full split and subsequent tail slicing and joining.
Preserve negative-limit handling and positive limits removing empty
values. Empty values must be filtered before folding the tail, whose
internal whitespace must remain intact.
PHP 8.5 benchmarks with OPCache enabled show 28-37% less runtime for
padded lists removing empty values. A 100,000-value mixed list uses 30%
less peak memory. Splitting 1,000 values with a limit of two is 36
times faster and uses 76% less peak memory. These are isolated method
measurements, not application-wide performance claims.
Add coverage for empty input, trim whitespace, form feed and zero.
Reviews 1
History 18
-
Gerrit Code Review pushed patch set 2 for main to change 96330 status
NewUnder Review <span data-processor="relativetime" data-value="2026-10-09T16:39:01+00:00" > 10/09/26, 16:39 </span> -
Gerrit Code Review pushed patch set 3 for main to change 96330 <span data-processor="relativetime" data-value="2026-10-09T16:39:05+00:00" > 10/09/26, 16:39 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 96330 <span data-processor="relativetime" data-value="2026-10-19T21:00:18+00:00" > 10/19/26, 21:00 </span>
-
Gerrit Code Review pushed patch set 5 for main to change 96330 <span data-processor="relativetime" data-value="2026-10-20T16:41:19+00:00" > 10/20/26, 16:41 </span>
-
Gerrit Code Review pushed patch set 6 for main to change 96330 <span data-processor="relativetime" data-value="2026-10-21T10:42:57+00:00" > 10/21/26, 10:42 </span>
-
Gerrit Code Review pushed patch set 6 for main to change 96330 <span data-processor="relativetime" data-value="2026-10-21T10:42:58+00:00" > 10/21/26, 10:42 </span>
-
Gerrit Code Review pushed patch set 7 for main to change 96330 <span data-processor="relativetime" data-value="2026-10-21T10:43:43+00:00" > 10/21/26, 10:43 </span>
-
Wouter Wolters commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-10-21T11:35:13+00:00" > 10/21/26, 11:35 </span>
Applied in changeset commit:308b8fd6d89df7b1d50b7ebcb55e63f37c57855b.