diff options
-rw-r--r-- | typedatabase.cpp | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/typedatabase.cpp b/typedatabase.cpp index 98ffc0b82..4ff2128ed 100644 --- a/typedatabase.cpp +++ b/typedatabase.cpp @@ -441,51 +441,57 @@ static bool compareTypeEntriesByName(const TypeEntry* t1, const TypeEntry* t2) return t1->qualifiedCppName() < t2->qualifiedCppName(); } -int getTypeIndex(const TypeEntry* typeEntry) -{ - if (computeTypeIndexes) { - TypeDatabase* tdb = TypeDatabase::instance(); - typedef QMap<int, QList<TypeEntry*> > GroupedTypeEntries; - GroupedTypeEntries groupedEntries; - - // Group type entries by revision numbers - TypeEntryHash allEntries = tdb->allEntries(); - foreach (QList<TypeEntry*> entryList, allEntries) { - foreach (TypeEntry* entry, entryList) { - if (entry->isPrimitive() - || entry->isContainer() - || entry->isFunction() - || !entry->generateCode() - || entry->isEnumValue() - || entry->isVarargs() - || entry->isTypeSystem() - || entry->isVoid() - || entry->isCustom()) - continue; - groupedEntries[getTypeRevision(entry)] << entry; - } +static void _computeTypeIndexes() +{ + TypeDatabase* tdb = TypeDatabase::instance(); + typedef QMap<int, QList<TypeEntry*> > GroupedTypeEntries; + GroupedTypeEntries groupedEntries; + + // Group type entries by revision numbers + TypeEntryHash allEntries = tdb->allEntries(); + foreach (QList<TypeEntry*> entryList, allEntries) { + foreach (TypeEntry* entry, entryList) { + if (entry->isPrimitive() + || entry->isContainer() + || entry->isFunction() + || !entry->generateCode() + || entry->isEnumValue() + || entry->isVarargs() + || entry->isTypeSystem() + || entry->isVoid() + || entry->isCustom()) + continue; + groupedEntries[getTypeRevision(entry)] << entry; } + } - maxTypeIndex = 0; - GroupedTypeEntries::iterator it = groupedEntries.begin(); - for (; it != groupedEntries.end(); ++it) { - // Remove duplicates - QList<TypeEntry*>::iterator newEnd = std::unique(it.value().begin(), it.value().end()); - it.value().erase(newEnd, it.value().end()); - // Sort the type entries by name - qSort(it.value().begin(), newEnd, compareTypeEntriesByName); - - foreach (TypeEntry* entry, it.value()) { - (*typeEntryFields())[entry].second = maxTypeIndex++; - } + maxTypeIndex = 0; + GroupedTypeEntries::iterator it = groupedEntries.begin(); + for (; it != groupedEntries.end(); ++it) { + // Remove duplicates + QList<TypeEntry*>::iterator newEnd = std::unique(it.value().begin(), it.value().end()); + it.value().erase(newEnd, it.value().end()); + // Sort the type entries by name + qSort(it.value().begin(), newEnd, compareTypeEntriesByName); + + foreach (TypeEntry* entry, it.value()) { + (*typeEntryFields())[entry].second = maxTypeIndex++; } } + computeTypeIndexes = false; +} +int getTypeIndex(const TypeEntry* typeEntry) +{ + if (computeTypeIndexes) + _computeTypeIndexes(); return typeEntryFields()->value(typeEntry).second; } int getMaxTypeIndex() { + if (computeTypeIndexes) + _computeTypeIndexes(); return maxTypeIndex; } |