summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2021-01-06 18:38:09 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2021-01-22 20:45:18 (GMT)
commit78569cb39857ca72f2ea45dfb2b56e98973ed5f4 (patch)
treeecfe4b6dabc6dc2a477316dd9a32988baf43627d
parent2370f5fed43d8a163f42ff60a7d2aeea5512b0d7 (diff)
downloadDoxygen-78569cb39857ca72f2ea45dfb2b56e98973ed5f4.zip
Doxygen-78569cb39857ca72f2ea45dfb2b56e98973ed5f4.tar.gz
Doxygen-78569cb39857ca72f2ea45dfb2b56e98973ed5f4.tar.bz2
Refactoring: modernize rtfFormatBmkStr
-rw-r--r--src/util.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 5494666..f59abc3 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -3293,7 +3293,7 @@ FileDef *findFileDef(const FileNameLinkedMap *fnMap,const char *n,bool &ambig)
ambig=FALSE;
if (n==0) return 0;
- std::unique_lock<std::mutex> lock(g_findFileDefMutex);
+ std::lock_guard<std::mutex> lock(g_findFileDefMutex);
const int maxAddrSize = 20;
char addr[maxAddrSize];
@@ -3715,7 +3715,7 @@ QCString convertNameToFile(const char *name,bool allowDots,bool allowUnderscore)
QCString result;
if (shortNames) // use short names only
{
- std::unique_lock<std::mutex> lock(g_usedNamesMutex);
+ std::lock_guard<std::mutex> lock(g_usedNamesMutex);
auto kv = g_usedNames.find(name);
uint num=0;
if (kv!=g_usedNames.end())
@@ -5248,29 +5248,25 @@ QCString latexFilterURL(const char *s)
return result.data();
}
+static std::mutex g_rtfFormatMutex;
+static std::unordered_map<std::string,std::string> g_tagMap;
+static QCString g_nextTag( "AAAAAAAAAA" );
QCString rtfFormatBmkStr(const char *name)
{
- static QCString g_nextTag( "AAAAAAAAAA" );
- static QDict<QCString> g_tagDict( 5003 );
-
- g_tagDict.setAutoDelete(TRUE);
+ std::lock_guard<std::mutex> lock(g_rtfFormatMutex);
// To overcome the 40-character tag limitation, we
// substitute a short arbitrary string for the name
// supplied, and keep track of the correspondence
// between names and strings.
- QCString key( name );
- QCString* tag = g_tagDict.find( key );
- if ( !tag )
+ QCString tag = g_nextTag;
+ auto result = g_tagMap.insert( std::make_pair(name, g_nextTag) );
+
+ if (result.second) // new item was added
{
- // This particular name has not yet been added
- // to the list. Add it, associating it with the
- // next tag value, and increment the next tag.
- tag = new QCString( g_nextTag.copy() ); // Make sure to use a deep copy!
- g_tagDict.insert( key, tag );
+ // increment the next tag.
- // This is the increment part
char* nxtTag = g_nextTag.rawData() + g_nextTag.length() - 1;
for ( unsigned int i = 0; i < g_nextTag.length(); ++i, --nxtTag )
{
@@ -5287,7 +5283,7 @@ QCString rtfFormatBmkStr(const char *name)
}
//printf("Name = %s RTF_tag = %s\n",name,(*tag).data());
- return *tag;
+ return tag;
}
bool checkExtension(const char *fName, const char *ext)