RE: [PHP-DEV] [RFC] Add clamp function

From: Date: Fri, 22 Aug 2025 11:30:26 +0000
Subject: RE: [PHP-DEV] [RFC] Add clamp function
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-128525@lists.php.net to get a copy of this message
From: Kyle Katarn <kylekatarnls@gmail.com> Sent: Friday, August 22, 2025 11:02 AM To: Christoph M. Becker <cmbecker69@gmx.de> Cc: Tim Düsterhus <tim@bastelstu.be>; PHP Internals <internals@lists.php.net> Subject: Re: [PHP-DEV] [RFC] Add clamp function > I created https://wiki.php.net/rfc/clamp_v2 (re-using most of > the info from https://wiki.php.net/rfc/clamp). Hey, I’m not against adding such a function, but I noticed that the RFC says > some of which use min > <https://www.php.net/manual/en/function.min.php> and max > <https://www.php.net/manual/en/function.max.php> to check the > bound, which is costly and slow when called often What makes them slow? If we can create a significantly faster clamp, can we use the same optimizations to improve min and max? BR, Juris

« previous php.internals (#128525) next »