forked from qt-creator/qt-creator
QmlDesigner: Use a static const QSet for keyword list
Makes the lookup faster. Also sort the keywords. Change-Id: I25ce0f2d1de7be572fecccc09b5ec12d81152e95 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
d75d94c8c0
commit
a1876a8509
@@ -29,8 +29,6 @@
|
||||
#include <model.h>
|
||||
#include <nodemetainfo.h>
|
||||
#include "internalnode_p.h"
|
||||
#include <QHash>
|
||||
#include <QTextStream>
|
||||
#include "invalidargumentexception.h"
|
||||
#include "invalididexception.h"
|
||||
#include "invalidmodelnodeexception.h"
|
||||
@@ -44,6 +42,10 @@
|
||||
#include "nodeproperty.h"
|
||||
#include <rewriterview.h>
|
||||
|
||||
#include <QHash>
|
||||
#include <QSet>
|
||||
#include <QTextStream>
|
||||
|
||||
namespace QmlDesigner {
|
||||
using namespace QmlDesigner::Internal;
|
||||
|
||||
@@ -143,34 +145,36 @@ QString ModelNode::validId()
|
||||
|
||||
static bool idIsQmlKeyWord(const QString& id)
|
||||
{
|
||||
QStringList keywords = { "import",
|
||||
"as",
|
||||
"break",
|
||||
"case",
|
||||
"catch",
|
||||
"continue",
|
||||
"debugger",
|
||||
"default",
|
||||
"delete",
|
||||
"do",
|
||||
"else",
|
||||
"finally",
|
||||
"for",
|
||||
"function",
|
||||
"if",
|
||||
"in",
|
||||
"instanceof",
|
||||
"new",
|
||||
"return",
|
||||
"switch",
|
||||
"this",
|
||||
"throw",
|
||||
"try",
|
||||
"typeof",
|
||||
"var",
|
||||
"void",
|
||||
"while",
|
||||
"with" };
|
||||
static const QSet<QString> keywords = {
|
||||
"as",
|
||||
"break",
|
||||
"case",
|
||||
"catch",
|
||||
"continue",
|
||||
"debugger",
|
||||
"default",
|
||||
"delete",
|
||||
"do",
|
||||
"else",
|
||||
"finally",
|
||||
"for",
|
||||
"function",
|
||||
"if",
|
||||
"import",
|
||||
"in",
|
||||
"instanceof",
|
||||
"new",
|
||||
"return",
|
||||
"switch",
|
||||
"this",
|
||||
"throw",
|
||||
"try",
|
||||
"typeof",
|
||||
"var",
|
||||
"void",
|
||||
"while",
|
||||
"with"
|
||||
};
|
||||
|
||||
return keywords.contains(id);
|
||||
}
|
||||
|
Reference in New Issue
Block a user