History log of /php-src/ext/standard/array.c (Results 26 – 50 of 1127)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 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 ...


# 6ab50381 14-Jan-2023 Niels <7771979+nielsdos@users.noreply.github.com>

Make array_pad's $length warning less confusing (#10149)

Remove array_pad's arbitrary length restriction

The error message was wrong; it *is* possible to use a larger length.
Fu

Make array_pad's $length warning less confusing (#10149)

Remove array_pad's arbitrary length restriction

The error message was wrong; it *is* possible to use a larger length.
Furthermore, there is an arbitrary restriction on the new array's
length.

Fix both by checking the length against HT_MAX_SIZE.

show more ...


# 308fd311 04-Jan-2023 Max Kellermann

ext/{standard,json,random,...}: add missing includes


# d9651a94 10-Oct-2022 Dmitry Stogov

Fix GH-9697: array_walk($ffiInstance, function () {}) crashes due to expecting mutable array


Revision tags: php-8.2.0RC1, php-8.1.10, php-8.0.23
# bc4c0126 24-Aug-2022 Máté Kocsis

Declare ext/standard constants in stubs - part 1 (#9404)

Revision tags: php-8.0.23RC1, php-8.1.10RC1, php-8.2.0beta3
# 1094a859 12-Aug-2022 Christoph M. Becker

Merge branch 'PHP-8.1'

* PHP-8.1:
Fix GH-9296: `ksort` behaves incorrectly on arrays with mixed keys


# 7908aae3 12-Aug-2022 Christoph M. Becker

Merge branch 'PHP-8.0' into PHP-8.1

* PHP-8.0:
Fix GH-9296: `ksort` behaves incorrectly on arrays with mixed keys


# cd1aed8e 11-Aug-2022 Denis Vaksman

Fix GH-9296: `ksort` behaves incorrectly on arrays with mixed keys

The comparator function used at ksort in SORT_REGULAR mode
need to be consistent with basic comparison rules. These rul

Fix GH-9296: `ksort` behaves incorrectly on arrays with mixed keys

The comparator function used at ksort in SORT_REGULAR mode
need to be consistent with basic comparison rules. These rules
were changed in PHP-8.0 for numeric strings, but comparator
used at ksort kept the old behaviour. It leads to inconsistent
situations, when after ksort the first key is GREATER than some
of the next ones by according to the basic comparison operators.

Closes GH-9293.

show more ...

# ad04345e 04-Aug-2022 Christoph M. Becker

Fix GH-9244: Segfault with array_multisort + array_shift

After restructuring non-packed arrays, we either need to pack them if
possible, or to rehash them.

Closes GH-9247.

# 55f8c142 04-Aug-2022 Christoph M. Becker

Avoid unnecessary comparison

The first element of the `arrays` serves as base for the comparison, so
there is no need to compare it to itself.

Closes GH-9246.

Revision tags: php-8.2.0beta2, php-8.1.9, php-8.0.22
# 5c693c77 26-Jul-2022 Tim Düsterhus

Remove `->last_unsafe` from php_random_status (#9132)

Whenever ->last_unsafe is set to `true` an exception has been thrown. Thus we
can replace the check for `->last_unsafe` with a check

Remove `->last_unsafe` from php_random_status (#9132)

Whenever ->last_unsafe is set to `true` an exception has been thrown. Thus we
can replace the check for `->last_unsafe` with a check for `EG(exception)`
which is a much more natural way to ommunicate an error up the chain.

show more ...

Revision tags: php-8.1.9RC1, php-8.2.0beta1, php-8.0.22RC1
# 4d8dd8d2 19-Jul-2022 Go Kudo

Implement Random Extension

https://wiki.php.net/rfc/rng_extension
https://wiki.php.net/rfc/random_extension_improvement

# 75a9a5f3 11-Jul-2022 Tim Düsterhus

Add `zend_array_to_list()` (#8976)

* Add zend_array_to_list()

* Use `zend_array_to_list()` in `PHP_FUNCTION(array_values)`

12345678910>>...46