History log of /PHP-8.3/ext/standard/array.c (Results 1 – 25 of 1019)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 24a29492 19-Jul-2023 Ilija Tovilo

Fix uouv in array_column

column_long and index_long might not be set, but are still used as arguments.
They are not actually used if column_str is set, but it's better to initialize

Fix uouv in array_column

column_long and index_long might not be set, but are still used as arguments.
They are not actually used if column_str is set, but it's better to initialize
them anyway, if only to make MemorySanitizer happy.

show more ...


# 15bea9ed 03-Jul-2024 David Carlier

Fix GH-14775: range overflow on negative step.

overflow occurs since we only deal with positive steps.

close GH-14778


# b06d6dba 03-Feb-2024 David Carlier

Forgotten piece of GH-13309/GH-13310 previous PR


# d91224cd 03-Feb-2024 David Carlier

Fix GH-13309 and GH-13310: array hashes comparison, wrong buffer len calculation.

php_array_key_compare_string_case_unstable_i has a typo for the second
operand resulting in a wrong buff

Fix GH-13309 and GH-13310: array hashes comparison, wrong buffer len calculation.

php_array_key_compare_string_case_unstable_i has a typo for the second
operand resulting in a wrong buffer size calculation.

Issue reported by @AlexRudyuk

Close GH-13315

show more ...


# d65c3950 31-Jan-2024 Ilija Tovilo

Fix instable array during in-place modification in uksort

The array isn't just observable if the array has RCn, but also if it is inside a
reference that is RCn. By-ref parameters are al

Fix instable array during in-place modification in uksort

The array isn't just observable if the array has RCn, but also if it is inside a
reference that is RCn. By-ref parameters are always RCn and as such always
observable.

Fixes GH-13279
Closes GH-13285

show more ...


# 00ea756c 14-Jan-2024 Tim Düsterhus

random/standard: Adjust #13138 for PHP 8.3


# 97c6da1d 14-Jan-2024 Tim Düsterhus

random/standard: Correctly handle broken engines in php_array_pick_keys (#13138)


# 1d6f344b 09-Jan-2024 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Fix GH-13094: range(9.9, '0') causes segmentation fault

`start_type + end_type < 2*IS_STRING` is not right, in this test case
the types are start_type==5 (IS_DOUBLE), end_type==7 (IS_ARR

Fix GH-13094: range(9.9, '0') causes segmentation fault

`start_type + end_type < 2*IS_STRING` is not right, in this test case
the types are start_type==5 (IS_DOUBLE), end_type==7 (IS_ARRAY).
The IS_ARRAY type is a sentinel to disambiguate single-byte strings.
The path must be taken when one of the types is not a string nor a
single-byte string. Therefore, use < IS_STRING with an OR condition.

Closes GH-13105.

show more ...


# 2053af66 19-Jul-2023 Ilija Tovilo

Fix uouv in array_column

column_long and index_long might not be set, but are still used as arguments.
They are not actually used if column_str is set, but it's better to initialize

Fix uouv in array_column

column_long and index_long might not be set, but are still used as arguments.
They are not actually used if column_str is set, but it's better to initialize
them anyway, if only to make MemorySanitizer happy.

show more ...


# 798c40a7 19-Jun-2023 George Peter Banyard

[RFC] Define proper semantics for range() function (#10826)

RFC: https://wiki.php.net/rfc/proper-range-semantics


# d5ad7510 08-Jun-2023 George Peter Banyard

More usage of known zend_str instead of C string (#11381)


# a02f7f24 06-Jun-2023 George Peter Banyard

Use more appropriate types for php_array_walk() function


# 15402454 02-Jun-2023 George Peter Banyard

ext/standard/array.c: Optimize min/max functions for int/float (#11194)

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>


# eb7ec15a 24-May-2023 Ilija Tovilo

Use single allocation for indirect values in array_multisort

Closes GH-11309


# b2ec6c24 23-May-2023 Ilija Tovilo

Fix exception handling in array_multisort()

Closes GH-11302


# f5c54fd8 23-May-2023 Ilija Tovilo

Fix access on NULL pointer in array_merge_recursive()

Closes GH-11303


# 646f54b5 06-May-2023 George Peter Banyard

ext/standard/array.c: use uint32_t instead of incorrect int type

Drive-by indentation fixes and bool usage


# 947eb952 24-Apr-2023 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Allow array functions to operate in-place if the refcount is 1 (#11060)

This allows array_merge, array_intersect, array_replace, array_unique
and usort to avoid taking a copy and do the

Allow array functions to operate in-place if the refcount is 1 (#11060)

This allows array_merge, array_intersect, array_replace, array_unique
and usort to avoid taking a copy and do the transformation in-place.

** Safety **

There are some array functions which take a copy of the input
array into a temporary C array for sorting purposes.
(e.g. array_unique, array_diff, and array_intersect do this).
Since we no longer take a copy in all cases, we must check if
it's possible that a value is accessed that was already destroyed.

For array_unique: cmpdata will never be removed so that will never reach
refcount 0. And when something is removed, it is the previous value of
cmpdata, not the one user later. So this seems okay.

For array_intersect: a previous pointer (ptr[0] - 1) is accessed.
But this can't be a destroyed value because the pointer is first moved forward.

For array_diff: it's possible a previous pointer is accessed after
destruction. So we can't optimise this case easily.

show more ...


# e8b8341d 04-Apr-2023 Ilija Tovilo

Support enums in array_unique

Fixes GH-9775
Closes GH-11015


# a0476fd3 14-Apr-2023 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Micro-optimize double comparison (#11061)

When using ZEND_NORMALIZE_BOOL(a - b) where a and b are doubles, this
generates the following instruction sequence on x64:
subsd xmm0, xmm

Micro-optimize double comparison (#11061)

When using ZEND_NORMALIZE_BOOL(a - b) where a and b are doubles, this
generates the following instruction sequence on x64:
subsd xmm0, xmm1
pxor xmm1, xmm1
comisd xmm0, xmm1
...

whereas if we use ZEND_THREEWAY_COMPARE we get two instructions less:
ucomisd xmm0, xmm1

The only difference is that the threeway compare uses *u*comisd instead
of comisd. The difference is that it will cause a FP signal if a
signaling NAN is used, but as far as I'm aware this doesn't matter for
our use case.

Similarly, the amount of instructions on AArch64 is also quite a bit
lower for this code compared to the old code.

** Results **

Using the benchmark https://gist.github.com/nielsdos/b36517d81a1af74d96baa3576c2b70df
I used hyperfine: hyperfine --runs 25 --warmup 3 './sapi/cli/php sort_double.php'
No extensions such as opcache used during benchmarking.

BEFORE THIS PATCH
-----------------
Time (mean ± σ): 255.5 ms ± 2.2 ms [User: 251.0 ms, System: 2.5 ms]
Range (min … max): 251.5 ms … 260.7 ms 25 runs

AFTER THIS PATCH
----------------
Time (mean ± σ): 236.2 ms ± 2.8 ms [User: 228.9 ms, System: 5.0 ms]
Range (min … max): 231.5 ms … 242.7 ms 25 runs

show more ...


# 3b066188 07-Mar-2023 George Peter Banyard

RFC: Saner array_(sum|product)() (#10161)

RFC: https://wiki.php.net/rfc/saner-array-sum-product

Moreover, the internal fast_add_function() function was removed.


# 3ff83334 07-Feb-2023 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Cleanup dead code in array_slice (#10539)

We can only get to this if condition if at least preserve_keys is true.
Therefore, the else branch of this check can never execute.


# fe2dc2b4 03-Feb-2023 Tyson Andre

Avoid crash for reset/end/next/prev() on ffi classes (#9711)

(And any PECLs returning `zend_empty_array` in the handler->get_properties
overrides)

Closes GH-9697

This i

Avoid crash for reset/end/next/prev() on ffi classes (#9711)

(And any PECLs returning `zend_empty_array` in the handler->get_properties
overrides)

Closes GH-9697

This is similar to the fix used in d9651a941915eb5fb5ad557090b65256fd8509b6
for array_walk.

This should make it safer for php-src (and PECLs, long-term) to return
the empty immutable array in `handler->get_properties` to avoid wasting memory.
See https://github.com/php/php-src/issues/9697#issuecomment-1273613175

The only possible internal iterator position for the empty array is at the end
of the empty array (nInternalPointer=0).
The `zend_hash*del*` helpers will always set nInternalPointer to 0 when an
array becomes empty,
regardless of previous insertions/deletions/updates to the array.

show more ...


# 7936c808 23-Jan-2023 Máté Kocsis

Fix GH-8329 Print true/false instead of bool in error and debug messages (#8385)


# c8955c07 16-Jan-2023 Christoph M. Becker

Revert GH-10220

Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit ecc880f491d66081298a16634629f149459706a9.
This reverts commit 588a07

Revert GH-10220

Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit ecc880f491d66081298a16634629f149459706a9.
This reverts commit 588a07f7371ee2b5fac17de147926780e427fae6.
This reverts commit f377e15751d3aa48b69cd9bcc366ede7803d511f.
This reverts commit b4ba16fe189b109144aff669e11d81365160104b.
This reverts commit 694ec1deea36e366b28b6349a52be49824e1a1a8.
This reverts commit 6b34de8eba9f66882ae16e6073af28783670ac53.
This reverts commit aa1cd02a4367834026ea2205ea13a2f904455aa1.
This reverts commit 308fd311ea6fcf3094b448df7f2b264f08e4fe4f.
This reverts commit 16203b53e1822a37b6ba6f2ab198bb435d05fdad.
This reverts commit 738fb5ca5412f5e833a7fab82b11519e635a3357.
This reverts commit 9fdbefacd3c382d731aa175b7bdc002ec9cb2b30.
This reverts commit cd4a7c1d90562ebb5f89caf94d00d579631b9fbe.
This reverts commit 928685eba2b2f0ded90e7f78fd806ea164002f6e.
This reverts commit 01e5ffc85cd4357fd7b5b7ceefa29f2d10ca26b7.

show more ...


12345678910>>...41