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:

committed by
Sven Neumann

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>
|
2005-03-26 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/display/gimpdisplayshell-close.c
|
* app/display/gimpdisplayshell-close.c
|
||||||
|
@ -353,24 +353,29 @@ lut_lookup (gfloat value,
|
|||||||
const gfloat *lut)
|
const gfloat *lut)
|
||||||
{
|
{
|
||||||
guchar offset = 128;
|
guchar offset = 128;
|
||||||
|
gint step = 64;
|
||||||
|
|
||||||
while (TRUE)
|
while (step)
|
||||||
{
|
{
|
||||||
if (lut[offset] < value)
|
if (lut[offset] < value)
|
||||||
{
|
{
|
||||||
if (offset == 255 || lut[offset + 1] >= value)
|
if (offset == 255 || lut[offset + 1] >= value)
|
||||||
return offset;
|
break;
|
||||||
|
|
||||||
offset++;
|
offset += step;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (offset == 0 || lut[offset - 1] < value)
|
if (offset == 0 || lut[offset - 1] < value)
|
||||||
return offset;
|
break;
|
||||||
|
|
||||||
offset--;
|
offset -= step;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
step /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user