Permalink
Browse files

Improved sorting performance for directories and files

  • Loading branch information...
Dimitri van Heesch
Dimitri van Heesch committed Jan 24, 2016
1 parent 6782795 commit 5475bf2e9a0f1517567186b47595b8dad2b6b3a3
Showing with 32 additions and 5 deletions.
  1. +30 −5 src/dirdef.cpp
  2. +2 −0 src/dirdef.h
@@ -67,17 +67,23 @@ bool DirDef::isLinkable() const
void DirDef::addSubDir(DirDef *subdir)
{
m_subdirs.inSort(subdir);
m_subdirs.append(subdir);
subdir->setOuterScope(this);
subdir->m_parent=this;
}
void DirDef::addFile(FileDef *fd)
{
m_fileList->inSort(fd);
m_fileList->append(fd);
fd->setDirDef(this);
}
void DirDef::sort()
{
m_subdirs.sort();
m_fileList->sort();
}
static QCString encodeDirName(const QCString &anchor)
{
// convert to md5 hash
@@ -593,11 +599,20 @@ void DirDef::computeDependencies()
//printf(" %d: add dependency %s->%s\n",count++,name().data(),usedDir->name().data());
addUsesDependency(usedDir,fd,ii->fileDef,FALSE);
}
}
}
}
}
}
}
if (m_usedDirs)
{
QDictIterator<UsedDir> udi(*m_usedDirs);
UsedDir *udir;
for (udi.toFirst();(udir=udi.current());++udi)
{
udir->sort();
}
}
}
bool DirDef::isParentOf(DirDef *dir) const
@@ -640,10 +655,15 @@ UsedDir::~UsedDir()
void UsedDir::addFileDep(FileDef *srcFd,FileDef *dstFd)
{
m_filePairs.inSort(srcFd->getOutputFileBase()+dstFd->getOutputFileBase(),
m_filePairs.append(srcFd->getOutputFileBase()+dstFd->getOutputFileBase(),
new FilePair(srcFd,dstFd));
}
void UsedDir::sort()
{
m_filePairs.sort();
}
FilePair *UsedDir::findFilePair(const char *name)
{
QCString n=name;
@@ -659,7 +679,7 @@ DirDef *DirDef::createNewDir(const char *path)
//printf("Adding new dir %s\n",path);
dir = new DirDef(path);
//printf("createNewDir %s short=%s\n",path,dir->shortName().data());
Doxygen::directories->inSort(path,dir);
Doxygen::directories->append(path,dir);
}
return dir;
}
@@ -919,6 +939,11 @@ void buildDirectories()
}
}
}
for (sdi.toFirst();(dir=sdi.current());++sdi)
{
dir->sort();
}
Doxygen::directories->sort();
computeCommonDirPrefix();
}
@@ -76,6 +76,7 @@ class DirDef : public Definition
static DirDef *mergeDirectoryInTree(const QCString &path);
bool visited;
void setDiskName(const QCString &name) { m_diskName = name; }
void sort();
private:
friend void computeDirDependencies();
@@ -138,6 +139,7 @@ class UsedDir
const FilePairDict &filePairs() const { return m_filePairs; }
const DirDef *dir() const { return m_dir; }
bool inherited() const { return m_inherited; }
void sort();
private:
DirDef *m_dir;

0 comments on commit 5475bf2

Please sign in to comment.