Skip to content

Commit

Permalink
Refactoring: replace Doxygen::memGrpInfoDict by Doxygen::memberGroupI…
Browse files Browse the repository at this point in the history
…nfoMap
  • Loading branch information
doxygen committed Dec 30, 2020
1 parent efa76fb commit 34ac30b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 40 deletions.
41 changes: 22 additions & 19 deletions src/docgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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)
}
Expand All @@ -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
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 6 additions & 7 deletions src/doxygen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
}


Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/doxygen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 10 additions & 5 deletions src/memberdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 34ac30b

Please sign in to comment.