From: Ivailo Monev Date: Wed, 25 Mar 2020 21:08:42 +0000 (+0000) Subject: replace if with switch statment in QColormap::pixel() X-Git-Tag: 4.12.0~3898 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c8db9c39c0a4a63ef0dc6cc6e31799be4a2dcfe1;p=kde%2FKatie.git replace if with switch statment in QColormap::pixel() Signed-off-by: Ivailo Monev --- diff --git a/src/gui/painting/qcolormap_x11.cpp b/src/gui/painting/qcolormap_x11.cpp index 4ede583c9..43b14950a 100644 --- a/src/gui/painting/qcolormap_x11.cpp +++ b/src/gui/painting/qcolormap_x11.cpp @@ -616,12 +616,16 @@ uint QColormap::pixel(const QColor &color) const const uint r = (c.ct.argb.red * d->r_max) >> 16; const uint g = (c.ct.argb.green * d->g_max) >> 16; const uint b = (c.ct.argb.blue * d->b_max) >> 16; - if (d->mode != Direct) { - if (d->mode == Gray) + + switch (d->mode) { + case Gray: return d->pixels.at((r * 30 + g * 59 + b * 11) / 100); - return d->pixels.at(r * d->g_max * d->b_max + g * d->b_max + b); + case Indexed: + return d->pixels.at(r * d->g_max * d->b_max + g * d->b_max + b); + case Direct: + return (r << d->r_shift) + (g << d->g_shift) + (b << d->b_shift); } - return (r << d->r_shift) + (g << d->g_shift) + (b << d->b_shift); + Q_UNREACHABLE(); } const QColor QColormap::colorAt(uint pixel) const