Skip to content

Commit 0818fae

Browse files
author
Ilia Alshanetsky
committed
Slight optimization in str_split() when split length is the same or greater
then the string length.
1 parent 14fac3d commit 0818fae

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ext/standard/string.c

+5
Original file line numberDiff line numberDiff line change
@@ -4782,6 +4782,11 @@ PHP_FUNCTION(str_split)
47824782

47834783
array_init(return_value);
47844784

4785+
if (split_length >= str_len) {
4786+
add_next_index_stringl(return_value, str, str_len, 1);
4787+
return;
4788+
}
4789+
47854790
n_reg_segments = floor(str_len / split_length);
47864791
p = str;
47874792

0 commit comments

Comments
 (0)