From 04ad22d326d2ce0e9997557c42d4ad82e25c6cd4 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 26 Dec 2021 23:32:51 +0900 Subject: [PATCH] [ELF] Refactor std::string_view::find_first_of() is faster than compiling a regex and runnning it. --- elf/passes.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/elf/passes.cc b/elf/passes.cc index 4f8710534e..714abbdc2f 100644 --- a/elf/passes.cc +++ b/elf/passes.cc @@ -609,9 +609,8 @@ void apply_version_script(Context &ctx) { for (VersionPattern &elem : ctx.arg.version_patterns) { std::vector vec; - std::regex re_glob("[*?]", std::regex_constants::optimize | std::regex_constants::nosubs); for (std::string_view pat : elem.patterns) { - if (!std::regex_search(pat.begin(), pat.end(), re_glob)) { + if (pat.find_first_of("*?") == pat.npos) { Symbol *sym = intern(ctx, pat); if (sym->file && !sym->file->is_dso) sym->ver_idx = elem.ver_idx;