mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 19:02:59 +00:00
optimize normalizeTypeInternal() QMetaObject helper function
there should be QByteArray::startsWith() overload that takes size argument for this purpose Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
74b09892e6
commit
9d64654862
1 changed files with 11 additions and 5 deletions
|
@ -189,6 +189,11 @@ static const struct TypeTblData {
|
|||
};
|
||||
static const qint16 TypeTblSize = sizeof(TypeTbl) / sizeof(TypeTblData);
|
||||
|
||||
static inline bool arrayStartsWith(const QByteArray &array, const char *array2, const int len) {
|
||||
return (qstrncmp(array.constData(), array2, len) == 0);
|
||||
}
|
||||
|
||||
|
||||
// This code is shared with moc.cpp
|
||||
static inline QByteArray normalizeTypeInternal(const char *t, const char *e)
|
||||
{
|
||||
|
@ -215,7 +220,7 @@ static inline QByteArray normalizeTypeInternal(const char *t, const char *e)
|
|||
while (searchindex > 0) {
|
||||
if (result.at(searchindex - 1) != '*') {
|
||||
result.remove(searchindex, 6);
|
||||
if (!result.startsWith("const ")) {
|
||||
if (!arrayStartsWith(result, "const ", 6)) {
|
||||
result.prepend("const ");
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +229,7 @@ static inline QByteArray normalizeTypeInternal(const char *t, const char *e)
|
|||
|
||||
// convert const reference to value and const value to value
|
||||
char lastchar = result.at(result.size()-1);
|
||||
if (result.startsWith("const ") && lastchar != '*') {
|
||||
if (arrayStartsWith(result, "const ", 6) && lastchar != '*') {
|
||||
result.remove(0, 6);
|
||||
if (lastchar == '&') {
|
||||
result.chop(1);
|
||||
|
@ -233,11 +238,12 @@ static inline QByteArray normalizeTypeInternal(const char *t, const char *e)
|
|||
|
||||
// discard 'struct', 'class', and 'enum'; they are optional
|
||||
// and we don't want them in the normalized signature
|
||||
if (result.startsWith("struct ")) {
|
||||
const char* resultdata = result.constData();
|
||||
if (arrayStartsWith(result, "struct ", 7)) {
|
||||
result.remove(0, 7);
|
||||
} else if (result.startsWith("class ")) {
|
||||
} else if (arrayStartsWith(result, "class ", 6)) {
|
||||
result.remove(0, 6);
|
||||
} else if (result.startsWith("enum ")) {
|
||||
} else if (arrayStartsWith(result, "enum ", 5)) {
|
||||
result.remove(0, 5);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue