diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2020-12-30 14:07:32 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2020-12-30 14:07:32 (GMT) |
commit | 34ac30b4e46023e0c86247dac4d47fce0ae1d4f8 (patch) | |
tree | 828e02737ed1f696f19b6369a1ae5e115109ef28 | |
parent | efa76fb818ff37ed2bde1675a11d36dc852727e5 (diff) | |
download | Doxygen-34ac30b4e46023e0c86247dac4d47fce0ae1d4f8.zip Doxygen-34ac30b4e46023e0c86247dac4d47fce0ae1d4f8.tar.gz Doxygen-34ac30b4e46023e0c86247dac4d47fce0ae1d4f8.tar.bz2 |
Refactoring: replace Doxygen::memGrpInfoDict by Doxygen::memberGroupInfoMap
-rw-r--r-- | src/docgroup.cpp | 41 | ||||
-rw-r--r-- | src/doxygen.cpp | 13 | ||||
-rw-r--r-- | src/doxygen.h | 4 | ||||
-rw-r--r-- | src/memberdef.cpp | 15 | ||||
-rw-r--r-- | src/util.cpp | 14 |
5 files changed, 47 insertions, 40 deletions
diff --git a/src/docgroup.cpp b/src/docgroup.cpp index d82d1b3..49fb9dc 100644 --- a/src/docgroup.cpp +++ b/src/docgroup.cpp @@ -3,8 +3,8 @@ * Copyright (C) 1997-2019 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -62,7 +62,7 @@ void DocGroup::enterCompound(const char *fileName,int line,const char *name) m_memberGroupDocs.resize(0); m_compoundName = name; int i = m_compoundName.find('('); - if (i!=-1) + if (i!=-1) { m_compoundName=m_compoundName.left(i); // strip category (Obj-C) } @@ -89,17 +89,15 @@ void DocGroup::leaveCompound(const char *,int,const char * /*name*/) int DocGroup::findExistingGroup(const MemberGroupInfo *info) { //printf("findExistingGroup %s:%s\n",info->header.data(),info->compoundName.data()); - QIntDictIterator<MemberGroupInfo> di(Doxygen::memGrpInfoDict); - MemberGroupInfo *mi; - for (di.toFirst();(mi=di.current());++di) + for (const auto &kv : Doxygen::memberGroupInfoMap) { - if (m_compoundName==mi->compoundName && // same file or scope - !mi->header.isEmpty() && // not a nameless group - qstricmp(mi->header,info->header)==0 // same header name + if (m_compoundName==kv.second->compoundName && // same file or scope + !kv.second->header.isEmpty() && // not a nameless group + qstricmp(kv.second->header,info->header)==0 // same header name ) { //printf("Found it!\n"); - return (int)di.currentKey(); // put the item in this group + return kv.first; // put the item in this group } } return ++g_groupId; // start new group @@ -119,13 +117,16 @@ void DocGroup::open(Entry *e,const char *,int, bool implicit) //printf(" membergroup id=%d %s\n",m_memberGroupId,m_memberGroupHeader.data()); if (m_memberGroupId==DOX_NOGROUP) // no group started yet { - MemberGroupInfo *info = new MemberGroupInfo; + auto info = std::make_unique<MemberGroupInfo>(); info->header = m_memberGroupHeader.stripWhiteSpace(); info->compoundName = m_compoundName; - m_memberGroupId = findExistingGroup(info); - //printf(" use membergroup %d\n",m_memberGroupId); - Doxygen::memGrpInfoDict.insert(m_memberGroupId,info); - + m_memberGroupId = findExistingGroup(info.get()); + auto it = Doxygen::memberGroupInfoMap.find(m_memberGroupId); + if (it==Doxygen::memberGroupInfoMap.end()) + { + //printf(" use membergroup %d\n",m_memberGroupId); + Doxygen::memberGroupInfoMap.insert(std::make_pair(m_memberGroupId,std::move(info))); + } m_memberGroupRelates = e->relates; e->mGrpId = m_memberGroupId; } @@ -149,9 +150,10 @@ void DocGroup::close(Entry *e,const char *fileName,int line,bool foundInline,boo // e->name.data(),e->section,fileName,line,m_autoGroupStack.size()); if (m_memberGroupId!=DOX_NOGROUP) // end of member group { - MemberGroupInfo *info=Doxygen::memGrpInfoDict.find(m_memberGroupId); - if (info) // known group + auto it = Doxygen::memberGroupInfoMap.find(m_memberGroupId); + if (it!=Doxygen::memberGroupInfoMap.end()) // known group { + auto &info = it->second; info->doc = m_memberGroupDocs; info->docFile = fileName; info->docLine = line; @@ -199,9 +201,10 @@ void DocGroup::addDocs(Entry *e) m_memberGroupDocs+="\n\n"; } m_memberGroupDocs+=e->doc; - MemberGroupInfo *info=Doxygen::memGrpInfoDict.find(m_memberGroupId); - if (info) + auto it =Doxygen::memberGroupInfoMap.find(m_memberGroupId); + if (it!=Doxygen::memberGroupInfoMap.end()) { + auto &info = it->second; info->doc = m_memberGroupDocs; info->docFile = e->docFile; info->docLine = e->docLine; diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 134636e..aab2483 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -134,10 +134,10 @@ FileNameLinkedMap *Doxygen::imageNameLinkedMap = 0; // images FileNameLinkedMap *Doxygen::dotFileNameLinkedMap = 0; // dot files FileNameLinkedMap *Doxygen::mscFileNameLinkedMap = 0; // msc files FileNameLinkedMap *Doxygen::diaFileNameLinkedMap = 0; // dia files -StringUnorderedMap Doxygen::namespaceAliasMap; // all namespace aliases -StringDict Doxygen::tagDestinationDict(257); // all tag locations -StringUnorderedSet Doxygen::expandAsDefinedSet; // all macros that should be expanded -QIntDict<MemberGroupInfo> Doxygen::memGrpInfoDict(1009); // dictionary of the member groups heading +StringUnorderedMap Doxygen::namespaceAliasMap; // all namespace aliases +StringDict Doxygen::tagDestinationDict(257); // all tag locations +StringUnorderedSet Doxygen::expandAsDefinedSet; // all macros that should be expanded +MemberGroupInfoMap Doxygen::memberGroupInfoMap; // dictionary of the member groups heading PageDef *Doxygen::mainPage = 0; bool Doxygen::insideMainPage = FALSE; // are we generating docs for the main page? NamespaceDefMutable *Doxygen::globalScope = 0; @@ -261,6 +261,8 @@ void statistics() Doxygen::mscFileNameDict->statistics(); fprintf(stderr,"--- diaFileNameDict stats ----\n"); Doxygen::diaFileNameDict->statistics(); + fprintf(stderr,"--- memGrpInfoDict stats ----\n"); + Doxygen::memGrpInfoDict.statistics(); #endif //fprintf(stderr,"--- g_excludeNameDict stats ----\n"); //g_excludeNameDict.statistics(); @@ -270,8 +272,6 @@ void statistics() Doxygen::tagDestinationDict.statistics(); fprintf(stderr,"--- g_compoundKeywordDict stats ----\n"); g_compoundKeywordDict.statistics(); - fprintf(stderr,"--- memGrpInfoDict stats ----\n"); - Doxygen::memGrpInfoDict.statistics(); } @@ -10151,7 +10151,6 @@ void initDoxygen() Doxygen::pageSDict->setAutoDelete(TRUE); Doxygen::exampleSDict = new PageSDict(1009); // all examples Doxygen::exampleSDict->setAutoDelete(TRUE); - Doxygen::memGrpInfoDict.setAutoDelete(TRUE); Doxygen::tagDestinationDict.setAutoDelete(TRUE); Doxygen::dirRelations.setAutoDelete(TRUE); Doxygen::indexList = new IndexList; diff --git a/src/doxygen.h b/src/doxygen.h index fb984f6..7f03f04 100644 --- a/src/doxygen.h +++ b/src/doxygen.h @@ -88,6 +88,8 @@ struct LookupInfo extern QCString g_spaces; +using MemberGroupInfoMap = std::unordered_map< int,std::unique_ptr<MemberGroupInfo> >; + /*! \brief This class serves as a namespace for global variables used by doxygen. * * All fields in this class are public and static, so they can be used directly. @@ -116,7 +118,7 @@ class Doxygen static NamespaceLinkedMap *namespaceLinkedMap; static StringDict tagDestinationDict; static StringDict aliasDict; - static QIntDict<MemberGroupInfo> memGrpInfoDict; + static MemberGroupInfoMap memberGroupInfoMap; static StringUnorderedSet expandAsDefinedSet; static NamespaceDefMutable *globalScope; static QCString htmlFileExtension; diff --git a/src/memberdef.cpp b/src/memberdef.cpp index ecc07d7..638af9e 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -2000,12 +2000,17 @@ bool MemberDefImpl::isBriefSectionVisible() const // "", //getFileDef()->name().data(), // argsString()); - MemberGroupInfo *info = Doxygen::memGrpInfoDict[m_impl->grpId]; - //printf("name=%s m_impl->grpId=%d info=%p\n",name().data(),m_impl->grpId,info); - //QCString *pMemGrp = Doxygen::memberDocDict[grpId]; - bool hasDocs = hasDocumentation() || + auto it = Doxygen::memberGroupInfoMap.find(m_impl->grpId); + bool hasDocs = hasDocumentation(); + if (it!=Doxygen::memberGroupInfoMap.end()) + { + auto &info = it->second; + //printf("name=%s m_impl->grpId=%d info=%p\n",name().data(),m_impl->grpId,info); + //QCString *pMemGrp = Doxygen::memberDocDict[grpId]; + hasDocs = hasDocs || // part of a documented member group - (m_impl->grpId!=-1 && info && !(info->doc.isEmpty() && info->header.isEmpty())); + (m_impl->grpId!=-1 && !(info->doc.isEmpty() && info->header.isEmpty())); + } // only include static members with file/namespace scope if // explicitly enabled in the config file diff --git a/src/util.cpp b/src/util.cpp index e4916cd..ac476b2 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -4435,11 +4435,10 @@ void addMembersToMemberGroup(MemberList *ml, int groupId=fmd->getMemberGroupId(); if (groupId!=-1) { - MemberGroupInfo *info = Doxygen::memGrpInfoDict[groupId]; - //QCString *pGrpHeader = Doxygen::memberHeaderDict[groupId]; - //QCString *pDocs = Doxygen::memberDocDict[groupId]; - if (info) + auto it = Doxygen::memberGroupInfoMap.find(groupId); + if (it!=Doxygen::memberGroupInfoMap.end()) { + auto &info = it->second; if (*ppMemberGroupSDict==0) { *ppMemberGroupSDict = new MemberGroupSDict; @@ -4468,11 +4467,10 @@ void addMembersToMemberGroup(MemberList *ml, int groupId=md->getMemberGroupId(); if (groupId!=-1) { - MemberGroupInfo *info = Doxygen::memGrpInfoDict[groupId]; - //QCString *pGrpHeader = Doxygen::memberHeaderDict[groupId]; - //QCString *pDocs = Doxygen::memberDocDict[groupId]; - if (info) + auto it = Doxygen::memberGroupInfoMap.find(groupId); + if (it!=Doxygen::memberGroupInfoMap.end()) { + auto &info = it->second; if (*ppMemberGroupSDict==0) { *ppMemberGroupSDict = new MemberGroupSDict; |