Skip to content

Commit

Permalink
Optimized use of convertNameToFile to improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri van Heesch committed Feb 7, 2016
1 parent ee2d6fa commit d168f8b
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 141 deletions.
69 changes: 31 additions & 38 deletions src/classdef.cpp
Expand Up @@ -62,6 +62,15 @@ class ClassDefImpl
*/
QCString fileName;

/*! file name used for the list of all members */
QCString memberListFileName;

/*! file name used for the collaboration diagram */
QCString collabFileName;

/*! file name used for the inheritance graph */
QCString inheritFileName;

/*! Include information about the header file should be included
* in the documentation. 0 by default, set by setIncludeFile().
*/
Expand Down Expand Up @@ -296,6 +305,13 @@ ClassDef::ClassDef(
m_impl->compType = ct;
m_impl->isJavaEnum = isJavaEnum;
m_impl->init(defFileName,name(),compoundTypeString(),fName);
m_impl->memberListFileName = convertNameToFile(compoundTypeString()+name()+"-members");
m_impl->collabFileName = convertNameToFile(m_impl->fileName+"_coll_graph");
m_impl->inheritFileName = convertNameToFile(m_impl->fileName+"_inherit_graph");
if (!lref)
{
m_impl->fileName = convertNameToFile(m_impl->fileName);
}
}

// destroy the class definition
Expand All @@ -306,7 +322,7 @@ ClassDef::~ClassDef()

QCString ClassDef::getMemberListFileName() const
{
return convertNameToFile(compoundTypeString()+name()+"-members");
return m_impl->memberListFileName;
}

QCString ClassDef::displayName(bool includeScope) const
Expand Down Expand Up @@ -3564,40 +3580,12 @@ QCString ClassDef::getOutputFileBase() const
// point to the template of which this class is an instance
return m_impl->templateMaster->getOutputFileBase();
}
else if (isReference())
{
// point to the external location
return m_impl->fileName;
}
else
{
// normal locally defined class
return convertNameToFile(m_impl->fileName);
}
return m_impl->fileName;
}

QCString ClassDef::getInstanceOutputFileBase() const
{
if (isReference())
{
return m_impl->fileName;
}
else
{
return convertNameToFile(m_impl->fileName);
}
}

QCString ClassDef::getFileBase() const
{
if (m_impl->templateMaster)
{
return m_impl->templateMaster->getFileBase();
}
else
{
return m_impl->fileName;
}
return m_impl->fileName;
}

QCString ClassDef::getSourceFileBase() const
Expand Down Expand Up @@ -4613,15 +4601,9 @@ QCString ClassDef::anchor() const
// point to the template of which this class is an instance
anc = m_impl->templateMaster->getOutputFileBase();
}
else if (isReference())
{
// point to the external location
anc = m_impl->fileName;
}
else
{
// normal locally defined class
anc = convertNameToFile(m_impl->fileName);
anc = m_impl->fileName;
}
}
return anc;
Expand Down Expand Up @@ -4750,3 +4732,14 @@ bool ClassDef::isAnonymous() const
{
return m_impl->isAnonymous;
}

QCString ClassDef::collaborationGraphFileName() const
{
return m_impl->collabFileName;
}

QCString ClassDef::inheritanceGraphFileName() const
{
return m_impl->inheritFileName;
}

7 changes: 6 additions & 1 deletion src/classdef.h
Expand Up @@ -108,7 +108,6 @@ class ClassDef : public Definition
/** Returns the unique base name (without extension) of the class's file on disk */
QCString getOutputFileBase() const;
QCString getInstanceOutputFileBase() const;
QCString getFileBase() const;

/** Returns the base name for the source code file */
QCString getSourceFileBase() const;
Expand All @@ -130,6 +129,12 @@ class ClassDef : public Definition

/** returns TRUE if this class has a non-empty detailed description */
bool hasDetailedDescription() const;

/** returns the file name to use for the collaboration graph */
QCString collaborationGraphFileName() const;

/** returns the file name to use for the inheritance graph */
QCString inheritanceGraphFileName() const;

/** Returns the name as it is appears in the documentation */
QCString displayName(bool includeScope=TRUE) const;
Expand Down
13 changes: 0 additions & 13 deletions src/definition.cpp
Expand Up @@ -1507,19 +1507,6 @@ QList<ListItemInfo> *Definition::xrefListItems() const
return m_impl->xrefListItems;
}


QCString Definition::convertNameToFile(const char *name,bool allowDots) const
{
if (!m_impl->ref.isEmpty())
{
return name;
}
else
{
return ::convertNameToFile(name,allowDots);
}
}

QCString Definition::pathFragment() const
{
QCString result;
Expand Down
1 change: 0 additions & 1 deletion src/definition.h
Expand Up @@ -326,7 +326,6 @@ class Definition : public DefinitionIntf
// --- actions ----
//-----------------------------------------------------------------------------------

QCString convertNameToFile(const char *name,bool allowDots=FALSE) const;
void writeSourceDef(OutputList &ol,const char *scopeName);
void writeInlineCode(OutputList &ol,const char *scopeName);
void writeSourceRefs(OutputList &ol,const char *scopeName);
Expand Down
56 changes: 16 additions & 40 deletions src/dot.cpp
Expand Up @@ -2953,7 +2953,8 @@ DotClassGraph::DotClassGraph(ClassDef *cd,DotNode::GraphType t)
openNodeQueue.append(m_startNode);
determineTruncatedNodes(openNodeQueue,t==DotNode::Inheritance);

m_diskName = cd->getFileBase().copy();
m_collabFileName = cd->collaborationGraphFileName();
m_inheritFileName = cd->inheritanceGraphFileName();
}

bool DotClassGraph::isTrivial() const
Expand Down Expand Up @@ -3071,27 +3072,6 @@ static bool updateDotGraph(DotNode *root,
return checkAndUpdateMd5Signature(baseName,md5); // graph needs to be regenerated
}

QCString DotClassGraph::diskName() const
{
QCString result=m_diskName.copy();
switch (m_graphType)
{
case DotNode::Collaboration:
result+="_coll_graph";
break;
//case Interface:
// result+="_intf_graph";
// break;
case DotNode::Inheritance:
result+="_inherit_graph";
break;
default:
ASSERT(0);
break;
}
return result;
}

QCString DotClassGraph::writeGraph(FTextStream &out,
GraphOutputFormat graphFormat,
EmbeddedOutputFormat textFormat,
Expand All @@ -3116,18 +3096,16 @@ QCString DotClassGraph::writeGraph(FTextStream &out,
{
case DotNode::Collaboration:
mapName="coll_map";
baseName=m_collabFileName;
break;
//case Interface:
// mapName="intf_map";
// break;
case DotNode::Inheritance:
mapName="inherit_map";
baseName=m_inheritFileName;
break;
default:
ASSERT(0);
break;
}
baseName = convertNameToFile(diskName());

// derive target file names from baseName
QCString imgExt = getDotImageExtension();
Expand Down Expand Up @@ -3425,8 +3403,9 @@ DotInclDepGraph::DotInclDepGraph(FileDef *fd,bool inverse)
{
m_inverse = inverse;
ASSERT(fd!=0);
m_diskName = fd->getFileBase().copy();
QCString tmp_url=fd->getReference()+"$"+fd->getFileBase();
m_inclDepFileName = fd->includeDependencyGraphFileName();
m_inclByDepFileName = fd->includedByDependencyGraphFileName();
QCString tmp_url=fd->getReference()+"$"+fd->getOutputFileBase();
m_startNode = new DotNode(m_curNodeNumber++,
fd->docName(),
"",
Expand Down Expand Up @@ -3458,14 +3437,6 @@ DotInclDepGraph::~DotInclDepGraph()
delete m_usedNodes;
}

QCString DotInclDepGraph::diskName() const
{
QCString result=m_diskName.copy();
if (m_inverse) result+="_dep";
result+="_incl";
return convertNameToFile(result);
}

QCString DotInclDepGraph::writeGraph(FTextStream &out,
GraphOutputFormat graphFormat,
EmbeddedOutputFormat textFormat,
Expand All @@ -3484,10 +3455,15 @@ QCString DotInclDepGraph::writeGraph(FTextStream &out,
}
static bool usePDFLatex = Config_getBool(USE_PDFLATEX);

QCString baseName=m_diskName;
if (m_inverse) baseName+="_dep";
baseName+="_incl";
baseName=convertNameToFile(baseName);
QCString baseName;
if (m_inverse)
{
baseName=m_inclByDepFileName;
}
else
{
baseName=m_inclDepFileName;
}
QCString mapName=escapeCharsInString(m_startNode->m_label,FALSE);
if (m_inverse) mapName+="dep";

Expand Down
7 changes: 4 additions & 3 deletions src/dot.h
Expand Up @@ -180,7 +180,6 @@ class DotClassGraph
void writeXML(FTextStream &t);
void writeDocbook(FTextStream &t);
void writeDEF(FTextStream &t);
QCString diskName() const;
static void resetNumbering();

private:
Expand All @@ -195,7 +194,8 @@ class DotClassGraph
QDict<DotNode> * m_usedNodes;
static int m_curNodeNumber;
DotNode::GraphType m_graphType;
QCString m_diskName;
QCString m_collabFileName;
QCString m_inheritFileName;
bool m_lrRank;
};

Expand Down Expand Up @@ -223,7 +223,8 @@ class DotInclDepGraph
DotNode *m_startNode;
QDict<DotNode> *m_usedNodes;
static int m_curNodeNumber;
QCString m_diskName;
QCString m_inclDepFileName;
QCString m_inclByDepFileName;
bool m_inverse;
};

Expand Down
30 changes: 26 additions & 4 deletions src/filedef.cpp
Expand Up @@ -82,8 +82,7 @@ FileDef::FileDef(const char *p,const char *nm,
m_path=p;
m_filePath=m_path+nm;
m_fileName=nm;
m_diskName=dn;
if (m_diskName.isEmpty()) m_diskName=nm;
setDiskName(dn?dn:nm);
setReference(lref);
m_classSDict = 0;
m_includeList = 0;
Expand Down Expand Up @@ -125,6 +124,13 @@ FileDef::~FileDef()
delete m_memberGroupSDict;
}

void FileDef::setDiskName(const QCString &name)
{
m_outputDiskName = convertNameToFile(name);
m_inclDepFileName = convertNameToFile(name+"_incl");
m_inclByDepFileName = convertNameToFile(name+"_dep_incl");
}

/*! Compute the HTML anchor names for all members in the class */
void FileDef::computeAnchors()
{
Expand Down Expand Up @@ -1769,17 +1775,22 @@ void FileDef::acquireFileVersion()


QCString FileDef::getSourceFileBase() const
{
{
if (Htags::useHtags)
{
return Htags::path2URL(m_filePath);
}
else
{
return convertNameToFile(m_diskName)+"_source";
return m_outputDiskName+"_source";
}
}

QCString FileDef::getOutputFileBase() const
{
return m_outputDiskName;
}

/*! Returns the name of the verbatim copy of this file (if any). */
QCString FileDef::includeName() const
{
Expand Down Expand Up @@ -1916,3 +1927,14 @@ QCString FileDef::fileVersion() const
{
return m_fileVersion;
}

QCString FileDef::includeDependencyGraphFileName() const
{
return m_inclDepFileName;
}

QCString FileDef::includedByDependencyGraphFileName() const
{
return m_inclByDepFileName;
}

0 comments on commit d168f8b

Please sign in to comment.