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:
Sven Neumann 2005-03-26 19:16:36 +00:00 committed by Sven Neumann
parent 93a4639895
commit 0f85f1453b
2 changed files with 15 additions and 5 deletions

View File

@ -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

View File

@ -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