summaryrefslogtreecommitdiffstats
path: root/src/doxygen.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2021-03-02 20:40:36 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2021-03-02 21:35:36 (GMT)
commit3d4f0313d20cc8f71ade094faa006a2171ff29c2 (patch)
tree0d84aff63e7b1bbd7bc46891771a90bc64ee58dc /src/doxygen.cpp
parent30d347bf8046775d6eab9bd8f70dbf3c3204e7b7 (diff)
downloadDoxygen-3d4f0313d20cc8f71ade094faa006a2171ff29c2.zip
Doxygen-3d4f0313d20cc8f71ade094faa006a2171ff29c2.tar.gz
Doxygen-3d4f0313d20cc8f71ade094faa006a2171ff29c2.tar.bz2
Refactoring: replaced std::regex with own much faster implementation
Diffstat (limited to 'src/doxygen.cpp')
-rw-r--r--src/doxygen.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index d4127a7..ce89540 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -31,7 +31,6 @@
#include <unordered_map>
#include <memory>
#include <cinttypes>
-#include <regex>
#include "version.h"
#include "doxygen.h"
@@ -106,6 +105,7 @@
#include "threadpool.h"
#include "clangparser.h"
#include "symbolresolver.h"
+#include "regex.h"
#if USE_SQLITE3
#include <sqlite3.h>
@@ -2220,10 +2220,10 @@ static MemberDef *addVariableToFile(
{
ttype.stripPrefix("struct ");
ttype.stripPrefix("union ");
- static const std::regex re("[[:alpha:]\\x80-\\xFF_][[:alnum:]\\x80-\\xFF_]*", std::regex::optimize);
- std::smatch match;
+ static const reg::Ex re(R"(\a\w*)");
+ reg::Match match;
std::string typ = ttype.str();
- if (std::regex_search(typ,match,re))
+ if (reg::search(typ,match,re))
{
QCString typeValue = match.str();
ClassDefMutable *cd = getClassMutable(typeValue);
@@ -2439,11 +2439,11 @@ static int findFunctionPtr(const std::string &type,SrcLangExt lang, int *pLength
return -1; // Fortran and VHDL do not have function pointers
}
- static const std::regex re("\\([^)]*[*\\^][^)]*\\)", std::regex::optimize);
- std::smatch match;
+ static const reg::Ex re(R"(\([^)]*[*^][^)]*\))");
+ reg::Match match;
size_t i=std::string::npos;
size_t l=0;
- if (std::regex_search(type,match,re)) // contains (...*...)
+ if (reg::search(type,match,re)) // contains (...*...)
{
i = match.position();
l = match.length();
@@ -2532,12 +2532,12 @@ static bool isVarWithConstructor(const Entry *root)
}
for (const Argument &a : root->argList)
{
- static const std::regex initChars("[0-9\"'&*!^]+", std::regex::optimize);
- std::smatch match;
+ static const reg::Ex initChars(R"([\d"'&*!^]+)");
+ reg::Match match;
if (!a.name.isEmpty() || !a.defval.isEmpty())
{
std::string name = a.name.str();
- if (std::regex_search(name,match,initChars) && match.position()==0)
+ if (reg::search(name,match,initChars) && match.position()==0)
{
result=TRUE;
}
@@ -2567,15 +2567,15 @@ static bool isVarWithConstructor(const Entry *root)
goto done;
}
std::string atype = a.type.str();
- if (std::regex_search(atype,match,initChars) && match.position()==0)
+ if (reg::search(atype,match,initChars) && match.position()==0)
{
result=TRUE; // argument type starts with typical initializer char
goto done;
}
std::string resType=resolveTypeDef(ctx,a.type).str();
if (resType.empty()) resType=atype;
- static const std::regex idChars("[[:alpha:]\\x80-\\xFF_][[:alnum:]\\x80-\\xFF_]*", std::regex::optimize);
- if (std::regex_search(resType,match,idChars) && match.position()==0) // resType starts with identifier
+ static const reg::Ex idChars(R"(\a\w*)");
+ if (reg::search(resType,match,idChars) && match.position()==0) // resType starts with identifier
{
resType=match.str();
//printf("resType=%s\n",resType.data());
@@ -2625,9 +2625,9 @@ static void addVariable(const Entry *root,int isFuncPtr=-1)
type=name;
std::string sargs = args.str();
- static const std::regex reName("[[:alpha:]\\x80-\\xFF_][[:alnum:]\\x80-\\xFF_]*", std::regex::optimize);
- std::smatch match;
- if (std::regex_search(sargs,match,reName))
+ static const reg::Ex reName(R"(\a\w*)");
+ reg::Match match;
+ if (reg::search(sargs,match,reName))
{
name = match.str(); // e.g. 'var' in '(var[10])'
sargs = match.suffix().str(); // e.g. '[10]) in '(var[10])'
@@ -3816,9 +3816,9 @@ static TemplateNameMap getTemplateArgumentsInName(const ArgumentList &templateAr
int count=0;
for (const Argument &arg : templateArguments)
{
- static const std::regex re("[[:alpha:]\\x80-\\xFF_][[:alnum:]\\x80-\\xFF_:]*", std::regex::optimize);
- std::sregex_iterator it(name.begin(),name.end(),re);
- std::sregex_iterator end;
+ static const reg::Ex re(R"(\a[\w:]*)");
+ reg::Iterator it(name,re);
+ reg::Iterator end;
for (; it!=end ; ++it)
{
const auto &match = *it;
@@ -5325,9 +5325,9 @@ static QCString substituteTemplatesInString(
)
{
std::string dst;
- static const std::regex re("[[:alpha:]\\x80-\\xFF_][[:alnum:]\\x80-\\xFF_]*", std::regex::optimize);
- std::sregex_iterator it(src.begin(),src.end(),re);
- std::sregex_iterator end;
+ static const reg::Ex re(R"(\a\w*)");
+ reg::Iterator it(src,re);
+ reg::Iterator end;
//printf("type=%s\n",sa->type.data());
size_t p=0;
for (; it!=end ; ++it) // for each word in srcType