From b9759ebf04618c311004ee4fd975b7fa7e47ed5e Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Wed, 2 Sep 2009 10:11:20 +0200 Subject: Use QStringRef when parsing SVG color opacity. Reviewed-by: Kim --- src/svg/qsvghandler.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 9e46048..28a96de 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -742,7 +742,7 @@ static bool resolveColor(const QString &colorStr, QColor &color, QSvgHandler *ha return color.isValid(); } -static bool constructColor(const QString &colorStr, const QString &opacity, +static bool constructColor(const QString &colorStr, const QStringRef &opacity, QColor &color, QSvgHandler *handler) { if (!resolveColor(colorStr, color, handler)) @@ -856,9 +856,8 @@ static void parseColor(QSvgNode *, QSvgHandler *handler) { QString colorStr = attributes.color.toString(); - QString opacity = attributes.colorOpacity.toString(); QColor color; - if (constructColor(colorStr, opacity, color, handler)) { + if (constructColor(colorStr, attributes.colorOpacity, color, handler)) { handler->pushColor(color); } } @@ -2903,10 +2902,10 @@ static QSvgStyleProperty *createSolidColorNode(QSvgNode *parent, { Q_UNUSED(parent); Q_UNUSED(attributes); QString solidColorStr = attributes.value(QLatin1String("solid-color")).toString(); - QString solidOpacityStr = attributes.value(QLatin1String("solid-opacity")).toString(); + QStringRef solidOpacityStr = attributes.value(QLatin1String("solid-opacity")); if (solidOpacityStr.isEmpty()) - solidOpacityStr = attributes.value(QLatin1String("opacity")).toString(); + solidOpacityStr = attributes.value(QLatin1String("opacity")); QColor color; if (!constructColor(solidColorStr, solidOpacityStr, color, handler)) @@ -2958,7 +2957,6 @@ static bool parseStopNode(QSvgStyleProperty *parent, static_cast(parent); QString offsetStr = attrs.offset.toString(); QString colorStr = attrs.stopColor.toString(); - QString opacityStr = attrs.stopOpacity.toString(); QColor color; bool ok = true; @@ -2969,7 +2967,7 @@ static bool parseStopNode(QSvgStyleProperty *parent, colorStr = QLatin1String("#000000"); } - constructColor(colorStr, opacityStr, color, handler); + constructColor(colorStr, attrs.stopOpacity, color, handler); QGradient *grad = style->qgradient(); -- cgit v0.12