Skip to content

Commit

Permalink
Get rid of QDeclarativeUtils
Browse files Browse the repository at this point in the history
All the QChar methods needed by QtDeclarative have now
been optimized to achieve at least as good performance
as the QDeclarativeUtils versions.

Change-Id: I5b8dd58f9b597f716b53563d07d39d894c5dd666
Reviewed-on: http://codereview.qt-project.org/5059
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
  • Loading branch information
Kent Hansen authored and Qt by Nokia committed Sep 19, 2011
1 parent 85554f7 commit 9175109
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 127 deletions.
1 change: 0 additions & 1 deletion src/declarative/qml/ftw/ftw.pri
Expand Up @@ -9,7 +9,6 @@ HEADERS += \
$$PWD/qdeclarativerefcount_p.h \
$$PWD/qdeclarativepool_p.h \
$$PWD/qfieldlist_p.h \
$$PWD/qdeclarativeutils_p.h \
$$PWD/qfastmetabuilder_p.h \
$$PWD/qhashfield_p.h \

Expand Down
91 changes: 0 additions & 91 deletions src/declarative/qml/ftw/qdeclarativeutils_p.h

This file was deleted.

37 changes: 18 additions & 19 deletions src/declarative/qml/parser/qdeclarativejslexer.cpp
Expand Up @@ -43,7 +43,6 @@
#include "qdeclarativejsengine_p.h"
#include "qdeclarativejsmemorypool_p.h"

#include <private/qdeclarativeutils_p.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QVarLengthArray>
#include <QtCore/QDebug>
Expand Down Expand Up @@ -279,7 +278,7 @@ int Lexer::scanToken()
_validTokenText = false;
_tokenLinePtr = _lastLinePtr;

while (QDeclarativeUtils::isSpace(_char)) {
while (_char.isSpace()) {
if (_char == QLatin1Char('\n')) {
_tokenLinePtr = _codePtr;

Expand Down Expand Up @@ -418,19 +417,19 @@ int Lexer::scanToken()
return T_DIVIDE_;

case '.':
if (QDeclarativeUtils::isDigit(_char)) {
if (_char.isDigit()) {
QVarLengthArray<char,32> chars;

chars.append(ch.unicode()); // append the `.'

while (QDeclarativeUtils::isDigit(_char)) {
while (_char.isDigit()) {
chars.append(_char.unicode());
scanChar();
}

if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
if (QDeclarativeUtils::isDigit(_codePtr[0]) || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
QDeclarativeUtils::isDigit(_codePtr[1]))) {
if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
_codePtr[1].isDigit())) {

chars.append(_char.unicode());
scanChar(); // consume `e'
Expand All @@ -440,7 +439,7 @@ int Lexer::scanToken()
scanChar(); // consume the sign
}

while (QDeclarativeUtils::isDigit(_char)) {
while (_char.isDigit()) {
chars.append(_char.unicode());
scanChar();
}
Expand Down Expand Up @@ -667,7 +666,7 @@ int Lexer::scanToken()
}

default:
if (QDeclarativeUtils::isLetter(ch) || ch == QLatin1Char('$') || ch == QLatin1Char('_') || (ch == QLatin1Char('\\') && _char == QLatin1Char('u'))) {
if (ch.isLetter() || ch == QLatin1Char('$') || ch == QLatin1Char('_') || (ch == QLatin1Char('\\') && _char == QLatin1Char('u'))) {
bool identifierWithEscapeChars = false;
if (ch == QLatin1Char('\\')) {
identifierWithEscapeChars = true;
Expand All @@ -682,7 +681,7 @@ int Lexer::scanToken()
}
}
while (true) {
if (QDeclarativeUtils::isLetterOrNumber(_char) || _char == QLatin1Char('$') || _char == QLatin1Char('_')) {
if (_char.isLetterOrNumber() || _char == QLatin1Char('$') || _char == QLatin1Char('_')) {
if (identifierWithEscapeChars)
_tokenText += _char;

Expand Down Expand Up @@ -721,13 +720,13 @@ int Lexer::scanToken()
return kind;
}
}
} else if (QDeclarativeUtils::isDigit(ch)) {
} else if (ch.isDigit()) {
if (ch != QLatin1Char('0')) {
double integer = ch.unicode() - '0';

QChar n = _char;
const QChar *code = _codePtr;
while (QDeclarativeUtils::isDigit(n)) {
while (n.isDigit()) {
integer = integer * 10 + (n.unicode() - '0');
n = *code++;
}
Expand Down Expand Up @@ -761,7 +760,7 @@ int Lexer::scanToken()
}

// decimal integer literal
while (QDeclarativeUtils::isDigit(_char)) {
while (_char.isDigit()) {
chars.append(_char.unicode());
scanChar(); // consume the digit
}
Expand All @@ -770,14 +769,14 @@ int Lexer::scanToken()
chars.append(_char.unicode());
scanChar(); // consume `.'

while (QDeclarativeUtils::isDigit(_char)) {
while (_char.isDigit()) {
chars.append(_char.unicode());
scanChar();
}

if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
if (QDeclarativeUtils::isDigit(_codePtr[0]) || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
QDeclarativeUtils::isDigit(_codePtr[1]))) {
if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
_codePtr[1].isDigit())) {

chars.append(_char.unicode());
scanChar(); // consume `e'
Expand All @@ -787,15 +786,15 @@ int Lexer::scanToken()
scanChar(); // consume the sign
}

while (QDeclarativeUtils::isDigit(_char)) {
while (_char.isDigit()) {
chars.append(_char.unicode());
scanChar();
}
}
}
} else if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
if (QDeclarativeUtils::isDigit(_codePtr[0]) || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
QDeclarativeUtils::isDigit(_codePtr[1]))) {
if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
_codePtr[1].isDigit())) {

chars.append(_char.unicode());
scanChar(); // consume `e'
Expand All @@ -805,7 +804,7 @@ int Lexer::scanToken()
scanChar(); // consume the sign
}

while (QDeclarativeUtils::isDigit(_char)) {
while (_char.isDigit()) {
chars.append(_char.unicode());
scanChar();
}
Expand Down
19 changes: 9 additions & 10 deletions src/declarative/qml/qdeclarativecompiler.cpp
Expand Up @@ -62,7 +62,6 @@
#include "private/qdeclarativeglobal_p.h"
#include "private/qdeclarativebinding_p.h"
#include "private/qdeclarativev4compiler_p.h"
#include "private/qdeclarativeutils_p.h"

#include <QColor>
#include <QDebug>
Expand Down Expand Up @@ -127,7 +126,7 @@ bool QDeclarativeCompiler::isAttachedPropertyName(const QString &name)

bool QDeclarativeCompiler::isAttachedPropertyName(const QHashedStringRef &name)
{
return !name.isEmpty() && QDeclarativeUtils::isUpper(name.at(0));
return !name.isEmpty() && name.at(0).isUpper();
}

/*!
Expand All @@ -154,7 +153,7 @@ bool QDeclarativeCompiler::isSignalPropertyName(const QHashedStringRef &name)
for (int i = 2; i < ns; ++i) {
const QChar curr = name.at(i);
if (curr.unicode() == '_') continue;
if (QDeclarativeUtils::isUpper(curr)) return true;
if (curr.isUpper()) return true;
return false;
}
return false; // consists solely of underscores - invalid.
Expand Down Expand Up @@ -1463,7 +1462,7 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeScript::Property *prop, QDecl
// Note that the property name could start with any alpha or '_' or '$' character,
// so we need to do the lower-casing of the first alpha character.
for (int firstAlphaIndex = 0; firstAlphaIndex < name.size(); ++firstAlphaIndex) {
if (QDeclarativeUtils::isUpper(name.at(firstAlphaIndex))) {
if (name.at(firstAlphaIndex).isUpper()) {
name[firstAlphaIndex] = name.at(firstAlphaIndex).toLower();
break;
}
Expand Down Expand Up @@ -2310,7 +2309,7 @@ bool QDeclarativeCompiler::testQualifiedEnumAssignment(const QMetaProperty &prop
COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop.name())));

QString string = v->value.asString();
if (!QDeclarativeUtils::isUpper(string.at(0)))
if (!string.at(0).isUpper())
return true;

QStringList parts = string.split(QLatin1Char('.'));
Expand Down Expand Up @@ -2443,7 +2442,7 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeScript::Object *obj)
}
}

if (QDeclarativeUtils::isUpper(prop.name.at(0)))
if (prop.name.at(0).isUpper())
COMPILE_EXCEPTION(&prop, tr("Property names cannot begin with an upper case letter"));

if (enginePrivate->v8engine()->illegalNames().contains(prop.name))
Expand Down Expand Up @@ -2574,7 +2573,7 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeScript::Object *obj, Dyn
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
if (lastSlash > -1) {
QString nameBase = path.mid(lastSlash + 1, path.length()-lastSlash-5);
if (!nameBase.isEmpty() && QDeclarativeUtils::isUpper(nameBase.at(0)))
if (!nameBase.isEmpty() && nameBase.at(0).isUpper())
newClassName = nameBase.toUtf8() + "_QMLTYPE_" + QByteArray::number(uniqueClassId);
}
}
Expand Down Expand Up @@ -2891,16 +2890,16 @@ bool QDeclarativeCompiler::checkValidId(QDeclarativeScript::Value *v, const QStr
COMPILE_EXCEPTION(v, tr( "Invalid empty ID"));

QChar ch = val.at(0);
if (QDeclarativeUtils::isLetter(ch) && !QDeclarativeUtils::isLower(ch))
if (ch.isLetter() && !ch.isLower())
COMPILE_EXCEPTION(v, tr( "IDs cannot start with an uppercase letter"));

QChar u(QLatin1Char('_'));
if (!QDeclarativeUtils::isLetter(ch) && ch != u)
if (!ch.isLetter() && ch != u)
COMPILE_EXCEPTION(v, tr( "IDs must start with a letter or underscore"));

for (int ii = 1; ii < val.count(); ++ii) {
ch = val.at(ii);
if (!QDeclarativeUtils::isLetterOrNumber(ch) && ch != u)
if (!ch.isLetterOrNumber() && ch != u)
COMPILE_EXCEPTION(v, tr( "IDs must contain only letters, numbers, and underscores"));
}

Expand Down
7 changes: 3 additions & 4 deletions src/declarative/qml/qdeclarativedirparser.cpp
Expand Up @@ -42,7 +42,6 @@
#include "private/qdeclarativedirparser_p.h"
#include "qdeclarativeerror.h"
#include <private/qdeclarativeglobal_p.h>
#include <private/qdeclarativeutils_p.h>

#include <QtCore/QTextStream>
#include <QtCore/QFile>
Expand Down Expand Up @@ -141,9 +140,9 @@ bool QDeclarativeDirParser::parse()
while (index != length) {
const QChar ch = line.at(index);

if (QDeclarativeUtils::isSpace(ch)) {
if (ch.isSpace()) {
do { ++index; }
while (index != length && QDeclarativeUtils::isSpace(line.at(index)));
while (index != length && line.at(index).isSpace());

} else if (ch == QLatin1Char('#')) {
// recognized a comment
Expand All @@ -153,7 +152,7 @@ bool QDeclarativeDirParser::parse()
const int start = index;

do { ++index; }
while (index != length && !QDeclarativeUtils::isSpace(line.at(index)));
while (index != length && !line.at(index).isSpace());

const QString lexeme = line.mid(start, index - start);

Expand Down
3 changes: 1 addition & 2 deletions src/declarative/qml/v4/qdeclarativev4irbuilder.cpp
Expand Up @@ -44,7 +44,6 @@

#include <private/qsganchors_p_p.h> // For AnchorLine
#include <private/qdeclarativetypenamecache_p.h>
#include <private/qdeclarativeutils_p.h>

DEFINE_BOOL_CONFIG_OPTION(qmlVerboseCompiler, QML_VERBOSE_COMPILER)

Expand Down Expand Up @@ -583,7 +582,7 @@ bool QDeclarativeV4IRBuilder::visit(AST::FieldMemberExpression *ast)
break;

case IR::Name::AttachType:
if (QDeclarativeUtils::isUpper(name.at(0))) {
if (name.at(0).isUpper()) {
QByteArray utf8Name = name.toUtf8();
const char *enumName = utf8Name.constData();

Expand Down

0 comments on commit 9175109

Please sign in to comment.