Skip to content

Commit b6fe4f7

Browse files
committed
Optimize findFileDef locking
1 parent 406ab5c commit b6fe4f7

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/util.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,14 +3232,14 @@ FileDef *findFileDef(const FileNameLinkedMap *fnMap,const QCString &n,bool &ambi
32323232
ambig=FALSE;
32333233
if (n.isEmpty()) return 0;
32343234

3235-
std::lock_guard<std::mutex> lock(g_findFileDefMutex);
32363235

32373236
const int maxAddrSize = 20;
32383237
char addr[maxAddrSize];
32393238
qsnprintf(addr,maxAddrSize,"%p:",reinterpret_cast<const void*>(fnMap));
32403239
QCString key = addr;
32413240
key+=n;
32423241

3242+
std::lock_guard<std::mutex> lock(g_findFileDefMutex);
32433243
FindFileCacheElem *cachedResult = g_findFileDefCache.find(key.str());
32443244
//printf("key=%s cachedResult=%p\n",qPrint(key),cachedResult);
32453245
if (cachedResult)
@@ -3256,16 +3256,16 @@ FileDef *findFileDef(const FileNameLinkedMap *fnMap,const QCString &n,bool &ambi
32563256
QCString name=Dir::cleanDirPath(n.str());
32573257
QCString path;
32583258
int slashPos;
3259-
const FileName *fn;
3260-
if (name.isEmpty()) goto exit;
3259+
if (name.isEmpty()) return 0;
32613260
slashPos=std::max(name.findRev('/'),name.findRev('\\'));
32623261
if (slashPos!=-1)
32633262
{
32643263
path=name.left(slashPos+1);
32653264
name=name.right(name.length()-slashPos-1);
32663265
}
3267-
if (name.isEmpty()) goto exit;
3268-
if ((fn=fnMap->find(name)))
3266+
if (name.isEmpty()) return 0;
3267+
const FileName *fn = fnMap->find(name);
3268+
if (fn)
32693269
{
32703270
//printf("fn->size()=%zu\n",fn->size());
32713271
if (fn->size()==1)
@@ -3306,8 +3306,6 @@ FileDef *findFileDef(const FileNameLinkedMap *fnMap,const QCString &n,bool &ambi
33063306
{
33073307
//printf("not found!\n");
33083308
}
3309-
exit:
3310-
//delete cachedResult;
33113309
return 0;
33123310
}
33133311

0 commit comments

Comments
 (0)