On 2025-08-29 08:36, Tim Düsterhus wrote:


Since a big part of your argument in favor of the clamp() function is “performance” (both in your reply here and in the introduction to the RFC): Please add meaningful benchmarks to the RFC text that show how much faster clamp() is actually going to be compared to alternative solutions.

Another part of the argument is "complexity", as brought up in the original proposal. I notice that the offered implementation of this function relies entirely on zend_compare().

max/min special-case long and double arguments and compare them more directly, leaving cases like string/string, string/double, array/array, or boolean/null to be handled by zend_compare(). It is a lot more complex, turning less than a dozen lines (looping over and passing args to zend_compare()) into more than fifty, presumably for performance reasons. The extra complication may not be worth it if there are only two or three values being compared (long and double are the first types zend_compare tries).

Reply via email to