1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-21 18:08:01 +03:00

Optimize regexes

This commit is contained in:
Rui Ueyama 2021-07-07 21:46:23 +09:00
parent 6ae115ac69
commit 057fffb1dd
2 changed files with 3 additions and 2 deletions

View File

@ -1176,7 +1176,8 @@ void ObjectFile<E>::write_symtab(Context<E> &ctx) {
}
bool is_c_identifier(std::string_view name) {
static std::regex re("[a-zA-Z_][a-zA-Z0-9_]*");
static std::regex re("[a-zA-Z_][a-zA-Z0-9_]*",
std::regex_constants::optimize);
return std::regex_match(name.begin(), name.end(), re);
}

View File

@ -311,7 +311,7 @@ void sort_init_fini(Context<E> &ctx) {
Timer t(ctx, "sort_init_fini");
auto get_priority = [](InputSection<E> *isec) {
static std::regex re(R"(_array\.(\d+)$)");
static std::regex re(R"(_array\.(\d+)$)", std::regex_constants::optimize);
std::string name = isec->name().begin();
std::smatch m;
if (std::regex_search(name, m, re))