mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Simplify clamp_component
Surprise surprise: the compiler generates shorter, branch-free code if we don't try to be clever with signed/unsigned casting tricks. Change-Id: I93d2020b6127e7d43feee394b06a52aaeddf3b79
This commit is contained in:
parent
429a7e2c0a
commit
03a6eb63f1
1 changed files with 2 additions and 2 deletions
|
@ -83,8 +83,8 @@ union uint8_rgbyuv {
|
|||
|
||||
static inline int clamp_component(int x)
|
||||
{
|
||||
if ((unsigned)x > 255)
|
||||
x = x < 0 ? 0 : 255;
|
||||
if(x > 255) return 255;
|
||||
if(x < 0) return 0;
|
||||
return x;
|
||||
}
|
||||
#include <debug.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue