Skip to content

Commit

Permalink
[ELF] Refactor
Browse files Browse the repository at this point in the history
std::string_view::find_first_of() is faster than compiling a regex
and runnning it.
  • Loading branch information
rui314 committed Dec 26, 2021
1 parent 1228bf3 commit 04ad22d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions elf/passes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,8 @@ void apply_version_script(Context<E> &ctx) {
for (VersionPattern &elem : ctx.arg.version_patterns) {
std::vector<std::string_view> 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<E> *sym = intern(ctx, pat);
if (sym->file && !sym->file->is_dso)
sym->ver_idx = elem.ver_idx;
Expand Down

0 comments on commit 04ad22d

Please sign in to comment.