mirror of https://github.com/GNOME/gimp.git
actually do a binary search, not a linear search starting in the middle.
2005-03-26 Sven Neumann <sven@gimp.org> * modules/cdisplay_colorblind.c (lut_lookup): actually do a binary search, not a linear search starting in the middle.
This commit is contained in:
parent
93a4639895
commit
0f85f1453b
|
@ -1,3 +1,8 @@
|
|||
2005-03-26 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* modules/cdisplay_colorblind.c (lut_lookup): actually do a binary
|
||||
search, not a linear search starting in the middle.
|
||||
|
||||
2005-03-26 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/display/gimpdisplayshell-close.c
|
||||
|
|
|
@ -353,24 +353,29 @@ lut_lookup (gfloat value,
|
|||
const gfloat *lut)
|
||||
{
|
||||
guchar offset = 128;
|
||||
gint step = 64;
|
||||
|
||||
while (TRUE)
|
||||
while (step)
|
||||
{
|
||||
if (lut[offset] < value)
|
||||
{
|
||||
if (offset == 255 || lut[offset + 1] >= value)
|
||||
return offset;
|
||||
break;
|
||||
|
||||
offset++;
|
||||
offset += step;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (offset == 0 || lut[offset - 1] < value)
|
||||
return offset;
|
||||
break;
|
||||
|
||||
offset--;
|
||||
offset -= step;
|
||||
}
|
||||
|
||||
step /= 2;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue