summaryrefslogtreecommitdiffstats
path: root/src/svg/qsvghandler.cpp
diff options
context:
space:
mode:
authorAriya Hidayat <ariya.hidayat@nokia.com>2009-08-31 14:44:34 (GMT)
committerAriya Hidayat <ariya.hidayat@nokia.com>2009-08-31 14:55:35 (GMT)
commit48e07d39124068fef1734cfabc1c50a2f6a42007 (patch)
tree87e2ff5fb4369b4fc617f159fafedd9a1189a339 /src/svg/qsvghandler.cpp
parent89030379ea1c2621fca24d91eaff92aea44686da (diff)
downloadQt-48e07d39124068fef1734cfabc1c50a2f6a42007.zip
Qt-48e07d39124068fef1734cfabc1c50a2f6a42007.tar.gz
Qt-48e07d39124068fef1734cfabc1c50a2f6a42007.tar.bz2
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
Diffstat (limited to 'src/svg/qsvghandler.cpp')
-rw-r--r--src/svg/qsvghandler.cpp25
1 files changed, 24 insertions, 1 deletions
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<qreal> parseNumbersList(const QChar *&str)
return points;
}
+static inline void parseNumbersArray(const QChar *&str, QVarLengthArray<qreal, 8> &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<qreal> parsePercentageList(const QChar *&str)
{
QVector<qreal> points;
@@ -956,7 +978,8 @@ static QMatrix parseTransformationMatrix(const QString &value)
if (*str != QLatin1Char('('))
goto error;
++str;
- QVector<qreal> points = parseNumbersList(str);
+ QVarLengthArray<qreal, 8> points;
+ parseNumbersArray(str, points);
if (*str != QLatin1Char(')'))
goto error;
++str;