From 0b069049a176c4f8970f271e698489d9fc7d1da7 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sat, 17 Oct 2020 13:35:15 +0200 Subject: Performance tweak: Pass BaseClassList by const reference --- src/classdef.cpp | 12 ++++++------ src/classdef.h | 4 ++-- src/context.cpp | 6 +++--- src/context.h | 8 ++++---- src/index.cpp | 2 +- src/util.cpp | 6 +++--- src/util.h | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/classdef.cpp b/src/classdef.cpp index e797b05e..20ead94 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -82,9 +82,9 @@ class ClassDefImpl : public DefinitionImpl, public ClassDef virtual CompoundType compoundType() const; virtual QCString compoundTypeString() const; virtual BaseClassList baseClasses() const; - virtual void updateBaseClasses(BaseClassList bcd); + virtual void updateBaseClasses(const BaseClassList &bcd); virtual BaseClassList subClasses() const; - virtual void updateSubClasses(BaseClassList bcd); + virtual void updateSubClasses(const BaseClassList &bcd); virtual const MemberNameInfoLinkedMap &memberNameInfoLinkedMap() const; virtual Protection protection() const; virtual bool isLinkableInProject() const; @@ -512,8 +512,8 @@ class ClassDefAliasImpl : public DefinitionAliasImpl, public ClassDef virtual void addGroupedInheritedMembers(OutputList &,MemberListType, const ClassDef *,const QCString &) const {} virtual void writeTagFile(FTextStream &) {} - virtual void updateBaseClasses(BaseClassList) {} - virtual void updateSubClasses(BaseClassList) {} + virtual void updateBaseClasses(const BaseClassList &) {} + virtual void updateSubClasses(const BaseClassList &) {} virtual void setVisited(bool visited) const { m_visited = visited; } virtual bool isVisited() const { return m_visited; } @@ -4752,7 +4752,7 @@ BaseClassList ClassDefImpl::baseClasses() const return m_impl->inherits; } -void ClassDefImpl::updateBaseClasses(BaseClassList bcd) +void ClassDefImpl::updateBaseClasses(const BaseClassList &bcd) { m_impl->inherits = bcd; } @@ -4762,7 +4762,7 @@ BaseClassList ClassDefImpl::subClasses() const return m_impl->inheritedBy; } -void ClassDefImpl::updateSubClasses(BaseClassList bcd) +void ClassDefImpl::updateSubClasses(const BaseClassList &bcd) { m_impl->inheritedBy = bcd; } diff --git a/src/classdef.h b/src/classdef.h index bd06323..faaf0f6 100644 --- a/src/classdef.h +++ b/src/classdef.h @@ -160,14 +160,14 @@ class ClassDef : virtual public Definition virtual BaseClassList baseClasses() const = 0; /** Update the list of base classes to the one passed */ - virtual void updateBaseClasses(BaseClassList bcd) = 0; + virtual void updateBaseClasses(const BaseClassList &bcd) = 0; /** Returns the list of sub classes that directly derive from this class */ virtual BaseClassList subClasses() const = 0; /** Update the list of sub classes to the one passed */ - virtual void updateSubClasses(BaseClassList bcd) = 0; + virtual void updateSubClasses(const BaseClassList &bcd) = 0; /** Returns a dictionary of all members. This includes any inherited * members. Members are sorted alphabetically. diff --git a/src/context.cpp b/src/context.cpp index 614cc2d..05429d3 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -6670,7 +6670,7 @@ class NestingContext::Private : public GenericNodeListContext } } } - void addDerivedClasses(BaseClassList bcl,bool hideSuper) + void addDerivedClasses(const BaseClassList &bcl,bool hideSuper) { for (const auto &bcd : bcl) { @@ -6812,7 +6812,7 @@ void NestingContext::addClassHierarchy(const ClassSDict &classSDict,bool rootOnl p->addClassHierarchy(classSDict,rootOnly); } -void NestingContext::addDerivedClasses(BaseClassList bcl,bool hideSuper) +void NestingContext::addDerivedClasses(const BaseClassList &bcl,bool hideSuper) { p->addDerivedClasses(bcl,hideSuper); } @@ -8533,7 +8533,7 @@ class InheritanceListContext::Private : public GenericNodeListContext } }; -InheritanceListContext::InheritanceListContext(BaseClassList list, bool baseClasses) : RefCountedContext("InheritanceListContext") +InheritanceListContext::InheritanceListContext(const BaseClassList &list, bool baseClasses) : RefCountedContext("InheritanceListContext") { p = new Private; for (const auto &bcd : list) diff --git a/src/context.h b/src/context.h index 473c72f..c785664 100644 --- a/src/context.h +++ b/src/context.h @@ -452,7 +452,7 @@ class ClassInheritanceNodeContext : public RefCountedContext, public TemplateStr virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } - void addChildren(BaseClassList bcl,bool hideSuper); + void addChildren(const BaseClassList &bcl,bool hideSuper); private: ClassInheritanceNodeContext(const ClassDef *); @@ -550,7 +550,7 @@ class NestingContext : public RefCountedContext, public TemplateListIntf void addModules(const GroupSDict &modules); void addModules(const GroupList &modules); void addClassHierarchy(const ClassSDict &clDict,bool rootOnly); - void addDerivedClasses(BaseClassList bcl,bool hideSuper); + void addDerivedClasses(const BaseClassList &bcl,bool hideSuper); private: NestingContext(const NestingNodeContext *parent,int level); @@ -926,7 +926,7 @@ class InheritanceNodeContext : public RefCountedContext, public TemplateStructIn class InheritanceListContext : public RefCountedContext, public TemplateListIntf { public: - static InheritanceListContext *alloc(BaseClassList list,bool baseClasses) + static InheritanceListContext *alloc(const BaseClassList &list,bool baseClasses) { return new InheritanceListContext(list,baseClasses); } // TemplateListIntf @@ -937,7 +937,7 @@ class InheritanceListContext : public RefCountedContext, public TemplateListIntf virtual int release() { return RefCountedContext::release(); } private: - InheritanceListContext(BaseClassList list,bool baseClasses); + InheritanceListContext(const BaseClassList &list,bool baseClasses); ~InheritanceListContext(); class Private; Private *p; diff --git a/src/index.cpp b/src/index.cpp index e46a578..532f627 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -451,7 +451,7 @@ void addMembersToIndex(T *def,LayoutDocManager::LayoutPart part, //---------------------------------------------------------------------------- /*! Generates HTML Help tree of classes */ -static void writeClassTree(OutputList &ol,BaseClassList bcl,bool hideSuper,int level,FTVHelp* ftv,bool addToIndex) +static void writeClassTree(OutputList &ol,const BaseClassList &bcl,bool hideSuper,int level,FTVHelp* ftv,bool addToIndex) { if (bcl.empty()) return; bool started=FALSE; diff --git a/src/util.cpp b/src/util.cpp index 6045bac..2e31df7 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -2595,7 +2595,7 @@ exit: return prot; } -void trimBaseClassScope(BaseClassList bcl,QCString &s,int level=0) +void trimBaseClassScope(const BaseClassList &bcl,QCString &s,int level=0) { //printf("trimBaseClassScope level=%d '%s'\n",level,s.data()); for (const auto &bcd : bcl) @@ -4581,7 +4581,7 @@ int getPrefixIndex(const QCString &name) //---------------------------------------------------------------------------- -static void initBaseClassHierarchy(BaseClassList bcl) +static void initBaseClassHierarchy(const BaseClassList &bcl) { for (const auto &bcd : bcl) { @@ -4636,7 +4636,7 @@ void initClassHierarchy(ClassSDict *cl) //---------------------------------------------------------------------------- -bool hasVisibleRoot(BaseClassList bcl) +bool hasVisibleRoot(const BaseClassList &bcl) { for (const auto &bcd : bcl) { diff --git a/src/util.h b/src/util.h index 09b1d22..03296f9 100644 --- a/src/util.h +++ b/src/util.h @@ -310,7 +310,7 @@ QCString replaceAnonymousScopes(const QCString &s,const char *replacement=0); void initClassHierarchy(ClassSDict *cl); -bool hasVisibleRoot(BaseClassList bcl); +bool hasVisibleRoot(const BaseClassList &bcl); bool classHasVisibleChildren(const ClassDef *cd); bool namespaceHasVisibleChild(const NamespaceDef *nd,bool includeClasses,bool filterClasses,ClassDef::CompoundType ct); bool classVisibleInIndex(const ClassDef *cd); -- cgit v0.12