summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAriya Hidayat <ariya.hidayat@nokia.com>2009-09-02 09:05:02 (GMT)
committerAriya Hidayat <ariya.hidayat@nokia.com>2009-09-02 11:04:56 (GMT)
commitf8bd803e6eac2d5c25fec9cb50b54128c57b6725 (patch)
tree2bdbcec847b6ac035be8445c9a7d5ac241f0907c /src
parent13bcc92274d52fa6df2d636c78cf6ea457d670aa (diff)
downloadQt-f8bd803e6eac2d5c25fec9cb50b54128c57b6725.zip
Qt-f8bd803e6eac2d5c25fec9cb50b54128c57b6725.tar.gz
Qt-f8bd803e6eac2d5c25fec9cb50b54128c57b6725.tar.bz2
Minor speed-up when parsing SVG color.
Loading tiger.svg (tests/benchmarks/qsvgrenderer) enjoys 1% speed-up. Reviewed-by: Kim
Diffstat (limited to 'src')
-rw-r--r--src/svg/qsvghandler.cpp54
1 files changed, 34 insertions, 20 deletions
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index 9459af6..6620707 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -716,28 +716,42 @@ static bool resolveColor(const QStringRef &colorStr, QColor &color, QSvgHandler
QStringRef colorStrTr = trimRef(colorStr);
if (colorStrTr.isEmpty())
return false;
- if (colorStrTr == QLatin1String("rgb(")) {
- const QChar *s = colorStrTr.constData() + 4;
- QVector<qreal> compo = parseNumbersList(s);
- //1 means that it failed after reaching non-parsable
- //character which is going to be "%"
- if (compo.size() == 1) {
+
+ switch(colorStrTr.at(0).unicode()) {
+ case 'r': {
+ // starts with "rgb("
+ if (colorStrTr == QLatin1String("rgb(")) {
const QChar *s = colorStrTr.constData() + 4;
- compo = parsePercentageList(s);
- compo[0] *= (qreal)2.55;
- compo[1] *= (qreal)2.55;
- compo[2] *= (qreal)2.55;
- }
+ QVector<qreal> compo = parseNumbersList(s);
+ //1 means that it failed after reaching non-parsable
+ //character which is going to be "%"
+ if (compo.size() == 1) {
+ const QChar *s = colorStrTr.constData() + 4;
+ compo = parsePercentageList(s);
+ compo[0] *= (qreal)2.55;
+ compo[1] *= (qreal)2.55;
+ compo[2] *= (qreal)2.55;
+ }
- color = QColor(int(compo[0]),
- int(compo[1]),
- int(compo[2]));
- return true;
- } else if (colorStrTr == QT_INHERIT) {
- return false;
- } else if (colorStrTr == QLatin1String("currentColor")) {
- color = handler->currentColor();
- return true;
+ color = QColor(int(compo[0]),
+ int(compo[1]),
+ int(compo[2]));
+ return true;
+ }
+ }
+ break;
+ case 'c':
+ if (colorStrTr == QLatin1String("currentColor")) {
+ color = handler->currentColor();
+ return true;
+ }
+ break;
+ case 'i':
+ if (colorStrTr == QT_INHERIT)
+ return false;
+ break;
+ default:
+ break;
}
color = QColor(colorStrTr.toString());