.. _performances-slowfunctions: .. _slow-functions: Slow Functions ++++++++++++++ Avoid using those slow native PHP functions, and replace them with alternatives. +---------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+ | Slow Function | Faster | +---------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+ | `array_diff() `_ | `foreach() `_ | | `array_intersect() `_ | `foreach() `_ | | `array_key_exists() `_ | `isset() `_ and `array_key_exists() `_ | | `array_map() `_ | `foreach() `_ | | `array_search() `_ | `array_flip() `_ and `isset() `_ | | `array_udiff() `_ | Use another way | | `array_uintersect() `_ | Use another way | | `array_unshift() `_ | Use another way | | `array_walk() `_ | `foreach() `_ | | `in_array() `_ | `isset() `_ | | `preg_replace() `_ | `strpos() `_ | | `strstr() `_ | `strpos() `_ | | `uasort() `_ | Use another way | | `uksort() `_ | Use another way | | `usort() `_ | Use another way | | `array_unique() `_ | `array_keys() `_ and `array_count_values() `_ | +---------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+ `array_unique() `_ has been accelerated in PHP 7.2 and may be used directly from this version on : `Optimize `array_unique() `_ `_. `array_key_exists() `_ has been accelerated in PHP 7.4 and may be used directly from this version on : `Implement ZEND_ARRAY_KEY_EXISTS opcode to speed up `array_key_exists() `_ `_. .. code-block:: php Suggestions ___________ * Replace the slow function with a faster version * Remove the usage of the slow function Specs _____ +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Short name | Performances/SlowFunctions | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Changed Behavior `, :ref:`Performances ` | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.8.4 | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Severity | Major | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | ClearPHP | `avoid-those-slow-functions `__ | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Examples | :ref:`case-churchcrm-performances-slowfunctions`, :ref:`case-suitecrm-performances-slowfunctions` | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+--------------------------------------------------------------------------------------------------------------------------+