Skip to content

Commit 9ab5f68

Browse files
committed
Replace SDict with std::map
1 parent e0fa50b commit 9ab5f68

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

src/dot.cpp

+18-19
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ DotManager *DotManager::instance()
8383
return m_theInstance;
8484
}
8585

86-
DotManager::DotManager() : m_runners(), m_filePatchers(1009)
86+
DotManager::DotManager() : m_runners(), m_filePatchers()
8787
{
88-
m_filePatchers.setAutoDelete(TRUE);
8988
m_queue = new DotRunnerQueue;
9089
int i;
9190
int dotNumThreads = Config_getInt(DOT_NUM_THREADS);
@@ -130,25 +129,27 @@ DotRunner* DotManager::createRunner(const std::string &absDotName, const std::st
130129
{
131130
err("md5 hash does not match for two different runs of %s !\n", absDotName.data());
132131
}
132+
rv = runit->second.get();
133133
}
134+
assert(rv);
134135
return rv;
135136
}
136137

137-
DotFilePatcher *DotManager::createFilePatcher(const QCString &fileName)
138+
DotFilePatcher *DotManager::createFilePatcher(const std::string &fileName)
138139
{
139-
DotFilePatcher *patcher = m_filePatchers.find(fileName);
140-
if (patcher==0)
141-
{
142-
patcher = new DotFilePatcher(fileName);
143-
m_filePatchers.append(fileName,patcher);
144-
}
145-
return patcher;
140+
auto patcher = m_filePatchers.find(fileName);
141+
142+
if (patcher != m_filePatchers.end()) return &(patcher->second);
143+
144+
auto rv = m_filePatchers.emplace(fileName, fileName.c_str());
145+
assert(rv.second);
146+
return &(rv.first->second);
146147
}
147148

148149
bool DotManager::run() const
149150
{
150151
uint numDotRuns = m_runners.size();
151-
uint numFilePatchers = m_filePatchers.count();
152+
uint numFilePatchers = m_filePatchers.size();
152153
if (numDotRuns+numFilePatchers>1)
153154
{
154155
if (m_workers.count()==0)
@@ -236,27 +237,25 @@ bool DotManager::run() const
236237

237238
// patch the output file and insert the maps and figures
238239
i=1;
239-
SDict<DotFilePatcher>::Iterator di(m_filePatchers);
240-
const DotFilePatcher *fp;
241240
// since patching the svg files may involve patching the header of the SVG
242241
// (for zoomable SVGs), and patching the .html files requires reading that
243242
// header after the SVG is patched, we first process the .svg files and
244243
// then the other files.
245-
for (di.toFirst();(fp=di.current());++di)
244+
for (auto & fp : m_filePatchers)
246245
{
247-
if (fp->isSVGFile())
246+
if (fp.second.isSVGFile())
248247
{
249248
msg("Patching output file %d/%d\n",i,numFilePatchers);
250-
if (!fp->run()) return FALSE;
249+
if (!fp.second.run()) return FALSE;
251250
i++;
252251
}
253252
}
254-
for (di.toFirst();(fp=di.current());++di)
253+
for (auto& fp : m_filePatchers)
255254
{
256-
if (!fp->isSVGFile())
255+
if (!fp.second.isSVGFile())
257256
{
258257
msg("Patching output file %d/%d\n",i,numFilePatchers);
259-
if (!fp->run()) return FALSE;
258+
if (!fp.second.run()) return FALSE;
260259
i++;
261260
}
262261
}

src/dot.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ class DotManager
3636
public:
3737
static DotManager *instance();
3838
DotRunner* createRunner(const std::string& absDotName, const std::string& md5Hash);
39-
DotFilePatcher *createFilePatcher(const QCString &fileName);
39+
DotFilePatcher *createFilePatcher(const std::string &fileName);
4040
bool run() const;
4141

4242
private:
4343
DotManager();
4444
virtual ~DotManager();
4545

4646
std::map<std::string, std::unique_ptr<DotRunner>> m_runners;
47-
SDict<DotFilePatcher> m_filePatchers;
47+
std::map<std::string, DotFilePatcher> m_filePatchers;
4848
static DotManager *m_theInstance;
4949
DotRunnerQueue *m_queue;
5050
QList<DotWorkerThread> m_workers;

src/dotgraph.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ void DotGraph::generateCode(FTextStream &t)
233233
if (m_regenerate)
234234
{
235235
DotManager::instance()->
236-
createFilePatcher(absImgName())->
236+
createFilePatcher(absImgName().data())->
237237
addSVGConversion(m_relPath,FALSE,QCString(),m_zoomable,m_graphId);
238238
}
239239
int mapId = DotManager::instance()->
240-
createFilePatcher(m_fileName)->
240+
createFilePatcher(m_fileName.data())->
241241
addSVGObject(m_baseName,absImgName(),m_relPath);
242242
t << "<!-- SVG " << mapId << " -->" << endl;
243243
}
@@ -252,7 +252,7 @@ void DotGraph::generateCode(FTextStream &t)
252252
if (m_regenerate || !insertMapFile(t, absMapName(), m_relPath, getMapLabel()))
253253
{
254254
int mapId = DotManager::instance()->
255-
createFilePatcher(m_fileName)->
255+
createFilePatcher(m_fileName.data())->
256256
addMap(absMapName(), m_relPath, m_urlOnly, QCString(), getMapLabel());
257257
t << "<!-- MAP " << mapId << " -->" << endl;
258258
}
@@ -263,7 +263,7 @@ void DotGraph::generateCode(FTextStream &t)
263263
if (m_regenerate || !DotFilePatcher::writeVecGfxFigure(t,m_baseName,absBaseName()))
264264
{
265265
int figId = DotManager::instance()->
266-
createFilePatcher(m_fileName)->
266+
createFilePatcher(m_fileName.data())->
267267
addFigure(m_baseName,absBaseName(),FALSE /*TRUE*/);
268268
t << endl << "% FIG " << figId << endl;
269269
}

src/dotlegendgraph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void DotLegendGraph::writeGraph(const char *path)
2929
if (getDotImageExtension()=="svg")
3030
{
3131
DotManager::instance()->
32-
createFilePatcher(absBaseName()+Config_getString(HTML_FILE_EXTENSION))->
32+
createFilePatcher((absBaseName()+Config_getString(HTML_FILE_EXTENSION)).data())->
3333
addSVGObject("graph_legend", absImgName(),QCString());
3434
}
3535
}

src/dotrunner.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ DotRunner::DotRunner(const std::string& absDotName, const std::string& md5Hash)
151151
, m_md5Hash(md5Hash.data())
152152
, m_dotExe(Config_getString(DOT_PATH)+"dot")
153153
, m_cleanUp(Config_getBool(DOT_CLEANUP))
154+
, m_jobs()
154155
{
155156
}
156157

0 commit comments

Comments
 (0)