According to my profiling activities, GeneralUtility::array_merge_recursive_overrule has really bad performance. (~ 111 ms own time for a BE call, that ranks number 3 in the list of the most expensive calls based on own time sorting.)
Some tests show that this is due to many array copy actions during the recursive calls (foreach constructs with $val being a copy of possibly large subarrays).
- making the first parameter by reference thus working on the original array
- move the function from GeneralUtility to ArrayUtility
- deprecate the function in GeneralUtility, but still work on a copy of the first array there to preserve backwards compatibility
- change all calls in core to use the new method
This brings the own time of the function down to 42 ms on my test system, getting the function out of the expensive calls in TYPO3 CMS.
[TASK] Improve performance of array_merge_recursive_overrule
The method GeneralUtility::array_merge_recursive_overrule()
always works on a copy of the given array(s). This is highly
inefficient when it comes to really big arrays and recursion.
This patches moves the functionality into the class ArrayUtility
and changes the behaviour to use a reference to the
All calls in the core are adjusted accordingly.
Furthermore we deprecate the method in GeneralUtility and
preserve backward compatibility.
Reviewed-by: Michiel Roos
Tested-by: Michiel Roos
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny