aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/parser/qdeclarativejslexer.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-07-22 16:18:06 +1000
committerQt by Nokia <qt-info@nokia.com>2011-08-30 13:18:28 +0200
commitb048a40d7aab29b44d9c548292ab4b307d8d40c0 (patch)
tree2c4b207e475626fbb3a464c29c6f4ab858aa6039 /src/declarative/qml/parser/qdeclarativejslexer.cpp
parent7d397be0cb6ae8f90d07903ff061d1600af15cb8 (diff)
Special case integers and strings in lexer
Reduces the amount of copying for integer numbers and uses a raw QStringRef for unescaped strings. Change-Id: I2ad29f4c67be72495e3209081761b9a1bb503f26 Reviewed-on: http://codereview.qt.nokia.com/3773 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/declarative/qml/parser/qdeclarativejslexer.cpp')
-rw-r--r--src/declarative/qml/parser/qdeclarativejslexer.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp
index 6c6338bbd5..e904ff6a37 100644
--- a/src/declarative/qml/parser/qdeclarativejslexer.cpp
+++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp
@@ -530,11 +530,29 @@ again:
case '\'':
case '"': {
const QChar quote = ch;
- _tokenText.resize(0);
_validTokenText = true;
bool multilineStringLiteral = false;
+ const QChar *startCode = _codePtr;
+
+ while (!_char.isNull()) {
+ if (_char == QLatin1Char('\n') || _char == QLatin1Char('\\')) {
+ break;
+ } else if (_char == quote) {
+ _tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode);
+ scanChar();
+
+ return T_STRING_LITERAL;
+ }
+ scanChar();
+ }
+
+ _tokenText.resize(0);
+ startCode--;
+ while (startCode != _codePtr - 1)
+ _tokenText += *startCode++;
+
while (! _char.isNull()) {
if (_char == QLatin1Char('\n')) {
multilineStringLiteral = true;
@@ -692,6 +710,24 @@ again:
}
}
} else if (QDeclarativeUtils::isDigit(ch)) {
+ if (ch != '0') {
+ int integer = ch.unicode() - '0';
+
+ QChar n = _char;
+ const QChar *code = _codePtr;
+ while (QDeclarativeUtils::isDigit(n)) {
+ integer = integer * 10 + (n.unicode() - '0');
+ n = *code++;
+ }
+
+ if (n != QLatin1Char('.') && n != QLatin1Char('e') && n != QLatin1Char('E')) {
+ _codePtr = code - 1;
+ scanChar();
+ _tokenValue = integer;
+ return T_NUMERIC_LITERAL;
+ }
+ }
+
QVarLengthArray<char,32> chars;
chars.append(ch.unicode());