From 48e07d39124068fef1734cfabc1c50a2f6a42007 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Mon, 31 Aug 2009 16:44:34 +0200 Subject: Minor improvement when parsing matrix transformation in SVG. Create a specialized version of numbers parsing that works on a short QVarLengthArray since a transformation matrix has at most 6 elements. Reviewed-by: Kim --- src/svg/qsvghandler.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 6ff885a..371b845 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -64,6 +64,7 @@ #include "qdebug.h" #include "qmath.h" #include "qnumeric.h" +#include "qvarlengtharray.h" #include "private/qmath_p.h" #include "float.h" @@ -613,6 +614,27 @@ static QVector parseNumbersList(const QChar *&str) return points; } +static inline void parseNumbersArray(const QChar *&str, QVarLengthArray &points) +{ + while (*str == QLatin1Char(' ')) + ++str; + while (isDigit(str->unicode()) || + *str == QLatin1Char('-') || *str == QLatin1Char('+') || + *str == QLatin1Char('.')) { + + points.append(toDouble(str)); + + while (*str == QLatin1Char(' ')) + ++str; + if (*str == QLatin1Char(',')) + ++str; + + //eat the rest of space + while (*str == QLatin1Char(' ')) + ++str; + } +} + static QVector parsePercentageList(const QChar *&str) { QVector points; @@ -956,7 +978,8 @@ static QMatrix parseTransformationMatrix(const QString &value) if (*str != QLatin1Char('(')) goto error; ++str; - QVector points = parseNumbersList(str); + QVarLengthArray points; + parseNumbersArray(str, points); if (*str != QLatin1Char(')')) goto error; ++str; -- cgit v0.12