From d38df57916d5902abc9dbaf5891c14898ce675da Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Mon, 28 Oct 2019 21:56:03 +0100 Subject: Replaced QList with std::vector --- src/commentscan.l | 4 ++-- src/docgroup.cpp | 21 +++++++++--------- src/docgroup.h | 4 ++-- src/doxygen.cpp | 36 ++++++++++++++----------------- src/entry.cpp | 18 +++------------- src/entry.h | 2 +- src/groupdef.cpp | 51 +++++++++++++++++--------------------------- src/scanner.l | 64 ++++--------------------------------------------------- src/tagreader.cpp | 4 ++-- src/types.h | 1 - 10 files changed, 59 insertions(+), 146 deletions(-) diff --git a/src/commentscan.l b/src/commentscan.l index eef76d6..29bc1d9 100644 --- a/src/commentscan.l +++ b/src/commentscan.l @@ -2141,8 +2141,8 @@ RCSTAG "$"{ID}":"[^\n$]+"$" /* ----- handle argument of ingroup command ------- */ {LABELID} { // group id - current->groups->append( - new Grouping(yytext, Grouping::GROUPING_INGROUP) + current->groups.push_back( + Grouping(yytext, Grouping::GROUPING_INGROUP) ); inGroupParamFound=TRUE; } diff --git a/src/docgroup.cpp b/src/docgroup.cpp index ecaa1af..fbdb842 100644 --- a/src/docgroup.cpp +++ b/src/docgroup.cpp @@ -23,7 +23,6 @@ void DocGroup::enterFile(const char *fileName,int) { m_openCount = 0; - m_autoGroupStack.setAutoDelete(TRUE); m_autoGroupStack.clear(); m_memberGroupId = DOX_NOGROUP; m_memberGroupDocs.resize(0); @@ -40,7 +39,7 @@ void DocGroup::leaveFile(const char *fileName,int line) m_memberGroupId=DOX_NOGROUP; m_memberGroupRelates.resize(0); m_memberGroupDocs.resize(0); - if (!m_autoGroupStack.isEmpty()) + if (!m_autoGroupStack.empty()) { warn(fileName,line,"end of file while inside a group"); } @@ -109,10 +108,10 @@ void DocGroup::open(Entry *e,const char *,int, bool implicit) { if (!implicit) m_openCount++; //printf("==> openGroup(name=%s,sec=%x) m_autoGroupStack=%d\n", - // e->name.data(),e->section,m_autoGroupStack.count()); + // e->name.data(),e->section,m_autoGroupStack.size()); if (e->section==Entry::GROUPDOC_SEC) // auto group { - m_autoGroupStack.push(new Grouping(e->name,e->groupingPri())); + m_autoGroupStack.push_back(Grouping(e->name,e->groupingPri())); } else // start of a member group { @@ -148,7 +147,7 @@ void DocGroup::close(Entry *e,const char *fileName,int line,bool foundInline,boo } } //printf("==> closeGroup(name=%s,sec=%x,file=%s,line=%d) m_autoGroupStack=%d\n", - // e->name.data(),e->section,fileName,line,m_autoGroupStack.count()); + // 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); @@ -164,13 +163,13 @@ void DocGroup::close(Entry *e,const char *fileName,int line,bool foundInline,boo if (!foundInline) e->mGrpId=DOX_NOGROUP; //printf("new group id=%d\n",m_memberGroupId); } - else if (!m_autoGroupStack.isEmpty()) // end of auto group + else if (!m_autoGroupStack.empty()) // end of auto group { - Grouping *grp = m_autoGroupStack.pop(); + Grouping grp = m_autoGroupStack.back(); + m_autoGroupStack.pop_back(); // see bug577005: we should not remove the last group for e - if (!foundInline) e->groups->removeLast(); + if (!foundInline && !e->groups.empty()) e->groups.pop_back(); //printf("Removing %s e=%p\n",grp->groupname.data(),e); - delete grp; if (!foundInline) initGroupInfo(e); } } @@ -181,12 +180,12 @@ void DocGroup::initGroupInfo(Entry *e) // m_memberGroupRelates.data(),e); e->mGrpId = m_memberGroupId; e->relates = m_memberGroupRelates; - if (!m_autoGroupStack.isEmpty()) + if (!m_autoGroupStack.empty()) { //printf("Appending group %s to %s: count=%d entry=%p\n", // m_autoGroupStack.top()->groupname.data(), // e->name.data(),e->groups->count(),e); - e->groups->append(new Grouping(*m_autoGroupStack.top())); + e->groups.push_back(Grouping(m_autoGroupStack.back())); } } diff --git a/src/docgroup.h b/src/docgroup.h index 4775d90..47a0a3e 100644 --- a/src/docgroup.h +++ b/src/docgroup.h @@ -16,7 +16,7 @@ #ifndef DOCGROUP_H #define DOCGROUP_H -#include +#include #include #include "membergroup.h" @@ -47,7 +47,7 @@ class DocGroup int m_memberGroupId; QCString m_memberGroupRelates; QCString m_memberGroupDocs; - QStack m_autoGroupStack; + std::vector m_autoGroupStack; QCString m_compoundName; }; diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 1646bcc..a75a820 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -568,11 +568,9 @@ static void addPageToContext(PageDef *pd,Entry *root) static void addRelatedPage(Entry *root) { GroupDef *gd=0; - QListIterator gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + for (const Grouping &g : root->groups) { - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) break; + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) break; } //printf("---> addRelatedPage() %s gd=%p\n",root->name.data(),gd); QCString doc; @@ -759,12 +757,10 @@ static void buildFileList(const Entry *root) fd->setBriefDescription(root->brief,root->briefFile,root->briefLine); fd->addSectionsToDefinition(root->anchors); fd->setRefItems(root->sli); - QListIterator gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + for (const Grouping &g : root->groups) { GroupDef *gd=0; - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { gd->addFile(fd); fd->makePartOfGroup(gd); @@ -1947,12 +1943,13 @@ static void findUsingDirectives(const Entry *root) nd->setMetaData(root->metaData); nd->setInline((root->spec&Entry::Inline)!=0); - QListIterator gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + //QListIterator gli(*root->groups); + //Grouping *g; + //for (;(g=gli.current());++gli) + for (const Grouping &g : root->groups) { GroupDef *gd=0; - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) gd->addNamespace(nd); } @@ -3575,9 +3572,9 @@ static void buildFunctionList(const Entry *root) ) { GroupDef *gd=0; - if (root->groups->getFirst() && !root->groups->getFirst()->groupname.isEmpty()) + if (!root->groups.empty() && !root->groups.front().groupname.isEmpty()) { - gd = Doxygen::groupSDict->find(root->groups->getFirst()->groupname); + gd = Doxygen::groupSDict->find(root->groups.front().groupname); } //printf("match!\n"); //printf("mnd=%p rnd=%p nsName=%s rnsName=%s\n",mnd,rnd,nsName.data(),rnsName.data()); @@ -3641,16 +3638,15 @@ static void buildFunctionList(const Entry *root) md->enableReferencesRelation(md->hasReferencesRelation() || root->referencesRelation); // merge ingroup specifiers - if (md->getGroupDef()==0 && root->groups->getFirst()!=0) + if (md->getGroupDef()==0 && !root->groups.empty()) { addMemberToGroups(root,md); } - else if (md->getGroupDef()!=0 && root->groups->count()==0) + else if (md->getGroupDef()!=0 && root->groups.empty()) { //printf("existing member is grouped, new member not\n"); - root->groups->append(new Grouping(md->getGroupDef()->name(), md->getGroupPri())); } - else if (md->getGroupDef()!=0 && root->groups->getFirst()!=0) + else if (md->getGroupDef()!=0 && !root->groups.empty()) { //printf("both members are grouped\n"); } @@ -7455,7 +7451,7 @@ static void findEnumDocumentation(const Entry *root) md->setRefItems(root->sli); const GroupDef *gd=md->getGroupDef(); - if (gd==0 &&root->groups->getFirst()!=0) // member not grouped but out-of-line documentation is + if (gd==0 && !root->groups.empty()) // member not grouped but out-of-line documentation is { addMemberToGroups(root,md); } @@ -7489,7 +7485,7 @@ static void findEnumDocumentation(const Entry *root) md->setMemberGroupId(root->mGrpId); const GroupDef *gd=md->getGroupDef(); - if (gd==0 && root->groups->getFirst()!=0) // member not grouped but out-of-line documentation is + if (gd==0 && !root->groups.empty()) // member not grouped but out-of-line documentation is { addMemberToGroups(root,md); } diff --git a/src/entry.cpp b/src/entry.cpp index 9a8d0dd..625a448 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -38,8 +38,6 @@ Entry::Entry() num++; m_parent=0; section = EMPTY_SEC; - groups = new QList; - groups->setAutoDelete(TRUE); anchors = new QList; // Doxygen::sectionDict takes ownership of the items! //printf("Entry::Entry() tArgList=0\n"); mGrpId = -1; @@ -101,8 +99,6 @@ Entry::Entry(const Entry &e) bodyLine = e.bodyLine; endBodyLine = e.endBodyLine; mGrpId = e.mGrpId; - groups = new QList; - groups->setAutoDelete(TRUE); anchors = new QList; fileName = e.fileName; startLine = e.startLine; @@ -138,15 +134,8 @@ Entry::Entry(const Entry &e) } extends = e.extends; - - // deep copy group list - QListIterator gli(*e.groups); - Grouping *g; - for (;(g=gli.current());++gli) - { - groups->append(new Grouping(*g)); - } - + groups = e.groups; + QListIterator sli2(*e.anchors); SectionInfo *s; for (;(s=sli2.current());++sli2) @@ -164,7 +153,6 @@ Entry::~Entry() //printf("Deleting entry %d name %s type %x children %d\n", // num,name.data(),section,sublist->count()); - delete groups; delete anchors; delete sli; num--; @@ -292,7 +280,7 @@ void Entry::reset() metaData.resize(0); m_sublist.clear(); extends.clear(); - groups->clear(); + groups.clear(); anchors->clear(); argList.clear(); tArgLists.clear(); diff --git a/src/entry.h b/src/entry.h index c715d60..6146c57 100644 --- a/src/entry.h +++ b/src/entry.h @@ -292,7 +292,7 @@ class Entry int endBodyLine; //!< line number where the definition ends int mGrpId; //!< member group id std::vector extends; //!< list of base classes - QList *groups; //!< list of groups this entry belongs to + std::vector groups; //!< list of groups this entry belongs to QList *anchors; //!< list of anchors defined in this entry QCString fileName; //!< file this entry was extracted from int startLine; //!< start line of entry in the source diff --git a/src/groupdef.cpp b/src/groupdef.cpp index bcdb3d0..882cebd 100644 --- a/src/groupdef.cpp +++ b/src/groupdef.cpp @@ -1460,12 +1460,10 @@ void GroupDefImpl::writeQuickMemberLinks(OutputList &ol,const MemberDef *current void addClassToGroups(const Entry *root,ClassDef *cd) { - QListIterator gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + for (const Grouping &g : root->groups) { GroupDef *gd=0; - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { if (gd->addClass(cd)) { @@ -1478,14 +1476,12 @@ void addClassToGroups(const Entry *root,ClassDef *cd) void addNamespaceToGroups(const Entry *root,NamespaceDef *nd) { - //printf("root->groups->count()=%d\n",root->groups->count()); - QListIterator gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + //printf("root->groups.size()=%d\n",root->groups.size()); + for (const Grouping &g : root->groups) { GroupDef *gd=0; //printf("group '%s'\n",s->data()); - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { if (gd->addNamespace(nd)) nd->makePartOfGroup(gd); //printf("Namespace %s: in group %s\n",nd->name().data(),s->data()); @@ -1495,14 +1491,12 @@ void addNamespaceToGroups(const Entry *root,NamespaceDef *nd) void addDirToGroups(const Entry *root,DirDef *dd) { - //printf("*** root->groups->count()=%d\n",root->groups->count()); - QListIterator gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + //printf("*** root->groups.size()=%d\n",root->groups.size()); + for (const Grouping &g : root->groups) { GroupDef *gd=0; //printf("group '%s'\n",g->groupname.data()); - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { gd->addDir(dd); dd->makePartOfGroup(gd); @@ -1513,14 +1507,11 @@ void addDirToGroups(const Entry *root,DirDef *dd) void addGroupToGroups(const Entry *root,GroupDef *subGroup) { - //printf("addGroupToGroups for %s groups=%d\n",root->name.data(), - // root->groups?root->groups->count():-1); - QListIterator gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + //printf("addGroupToGroups for %s groups=%d\n",root->name.data(),root->groups.size()); + for (const Grouping &g : root->groups) { GroupDef *gd=0; - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { if (gd==subGroup) { @@ -1546,20 +1537,18 @@ void addMemberToGroups(const Entry *root,MemberDef *md) { //printf("addMemberToGroups: Root %p = %s, md %p=%s groups=%d\n", // root, root->name.data(), md, md->name().data(), root->groups->count() ); - QListIterator gli(*root->groups); - Grouping *g; // Search entry's group list for group with highest pri. Grouping::GroupPri_t pri = Grouping::GROUPING_LOWEST; GroupDef *fgd=0; - for (;(g=gli.current());++gli) + for (const Grouping &g : root->groups) { GroupDef *gd=0; - if (!g->groupname.isEmpty() && - (gd=Doxygen::groupSDict->find(g->groupname)) && - g->pri >= pri) + if (!g.groupname.isEmpty() && + (gd=Doxygen::groupSDict->find(g.groupname)) && + g.pri >= pri) { - if (fgd && gd!=fgd && g->pri==pri) + if (fgd && gd!=fgd && g.pri==pri) { warn(root->fileName.data(), root->startLine, "Member %s found in multiple %s groups! " @@ -1570,7 +1559,7 @@ void addMemberToGroups(const Entry *root,MemberDef *md) } fgd = gd; - pri = g->pri; + pri = g.pri; } } //printf("fgd=%p\n",fgd); @@ -1650,12 +1639,10 @@ void addMemberToGroups(const Entry *root,MemberDef *md) void addExampleToGroups(const Entry *root,PageDef *eg) { - QListIterator gli(*root->groups); - Grouping *g; - for (;(g=gli.current());++gli) + for (const Grouping &g : root->groups) { GroupDef *gd=0; - if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname))) + if (!g.groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g.groupname))) { gd->addExample(eg); eg->makePartOfGroup(gd); diff --git a/src/scanner.l b/src/scanner.l index 6fa5008..6524272 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -251,11 +251,6 @@ static void initEntry() current->stat = gstat; current->lang = language; //printf("*** initEntry() language=%d\n",language); - //if (!autoGroupStack.isEmpty()) - //{ - // //printf("Appending group %s\n",autoGroupStack.top()->groupname.data()); - // current->groups->append(new Grouping(*autoGroupStack.top())); - //} Doxygen::docGroup.initGroupInfo(current.get()); isTypedef=FALSE; } @@ -263,42 +258,6 @@ static void initEntry() //----------------------------------------------------------------------------- -///// remove any automatic grouping and add new one (if given) -//static void setCurrentGroup( QCString *newgroup, Grouping::GroupPri_t pri ) -//{ -// /* remove auto group name from current entry and discard it */ -// Grouping *g = current->groups->first(); -// int i=0; -// while (g) -// { -// if (g->pri <= Grouping::GROUPING_AUTO_DEF) -// { -// current->groups->remove(i); -// i--; -// } -// g=current->groups->next(); -// i++; -// } -// -// /* use new group name instead? */ -// if ( newgroup ) -// { -// current->groups->append(new Grouping(*newgroup, pri)); -// } -//} -// -//static int newMemberGroupId() -//{ -// static int curGroupId=0; -// return curGroupId++; -//} -// -// forward declarations -//static void startGroupInDoc(); -//static void endGroup(); - -//----------------------------------------------------------------------------- - static void lineCount() { static int tabSize = Config_getInt(TAB_SIZE); @@ -3510,10 +3469,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { mtype = Method; virt = Normal; - if (current->groups) - { - current->groups->clear(); - } + current->groups.clear(); initEntry(); } } @@ -4215,14 +4171,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) varEntry->brief = current->brief.copy(); varEntry->mGrpId = current->mGrpId; varEntry->initializer = current->initializer; - - // deep copy group list - QListIterator gli(*current->groups); - Grouping *g; - for (;(g=gli.current());++gli) - { - varEntry->groups->append(new Grouping(*g)); - } + varEntry->groups = current->groups; if (current->sli) // copy special list items { QListIterator li(*current->sli); @@ -7132,14 +7081,9 @@ static void parseCompounds(const std::unique_ptr &rt) // deep copy group list from parent (see bug 727732) static bool autoGroupNested = Config_getBool(GROUP_NESTED_COMPOUNDS); - if (autoGroupNested && rt->groups && ce->section!=Entry::ENUM_SEC && !(ce->spec&Entry::Enum)) + if (autoGroupNested && ce->section!=Entry::ENUM_SEC && !(ce->spec&Entry::Enum)) { - QListIterator gli(*rt->groups); - Grouping *g; - for (;(g=gli.current());++gli) - { - ce->groups->append(new Grouping(*g)); - } + ce->groups = rt->groups; } int ni=ce->name.findRev("::"); if (ni==-1) ni=0; else ni+=2; diff --git a/src/tagreader.cpp b/src/tagreader.cpp index c2a7aac..ef4888e 100644 --- a/src/tagreader.cpp +++ b/src/tagreader.cpp @@ -1201,7 +1201,7 @@ void TagFileParser::buildMemberList(const std::unique_ptr &ce,QListid = tmi->clangId; if (ce->section == Entry::GROUPDOC_SEC) { - me->groups->append(new Grouping(ce->name,Grouping::GROUPING_INGROUP)); + me->groups.push_back(Grouping(ce->name,Grouping::GROUPING_INGROUP)); } addDocAnchors(me,tmi->docAnchors); me->tagInfoData.tagName = m_tagName; @@ -1458,7 +1458,7 @@ void TagFileParser::buildLists(const std::unique_ptr &root) [&](const std::unique_ptr &e) { return e->name = *it; }); if (i!=children.end()) { - (*i)->groups->append(new Grouping(tgi->name,Grouping::GROUPING_INGROUP)); + (*i)->groups.push_back(Grouping(tgi->name,Grouping::GROUPING_INGROUP)); } } } diff --git a/src/types.h b/src/types.h index 4d305b6..189a93d 100644 --- a/src/types.h +++ b/src/types.h @@ -92,7 +92,6 @@ struct Grouping } Grouping( const char *gn, GroupPri_t p ) : groupname(gn), pri(p) {} - Grouping( const Grouping &g ) : groupname(g.groupname), pri(g.pri) {} QCString groupname; //!< name of the group GroupPri_t pri; //!< priority of this definition -- cgit v0.12