From: Ivailo Monev Date: Sun, 16 Jun 2019 17:49:00 +0000 (+0000) Subject: optimize QColor::colorNames() X-Git-Tag: 4.12.0~5763 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=90befe6e087bf80520004da67239332035c92bdf;p=kde%2FKatie.git optimize QColor::colorNames() Signed-off-by: Ivailo Monev --- diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp index 2b8c6c24c..7492d8d76 100644 --- a/src/gui/painting/qcolor_p.cpp +++ b/src/gui/painting/qcolor_p.cpp @@ -108,7 +108,7 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb) #define RGBCOLOR(r,g,b) (0xff000000 | (r << 16) | (g << 8) | b) static const struct RGBData { const char *name; - uint value; + const uint value; } rgbTbl[] = { { "aliceblue", RGBCOLOR(240, 248, 255) }, { "antiquewhite", RGBCOLOR(250, 235, 215) }, @@ -305,9 +305,11 @@ uint qt_get_rgb_val(const char *name) QStringList qt_get_colornames() { int i = 0; - QStringList lst; - for (i = 0; i < rgbTblSize; i++) - lst << QLatin1String(rgbTbl[i].name); + static QStringList lst; + if (lst.isEmpty()) { + for (i = 0; i < rgbTblSize; i++) + lst << QLatin1String(rgbTbl[i].name); + } return lst; }