Commit 0f85f145 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

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.
parent 93a46398
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, ...@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment