diff options
author | Josef Cejka <jcejka@suse.de> | 2022-08-03 13:33:21 +0200 |
---|---|---|
committer | Frank Ch. Eigler <fche@redhat.com> | 2022-08-03 10:25:11 -0400 |
commit | cc2b85c4536f415547981fc4cf176e3fae967acc (patch) | |
tree | 1c16605f74c7c3c70f47a3d480f30f7827ebb278 /debuginfod | |
parent | bcd7651eb06f2e57a04ca97ae69b42c174fe3db3 (diff) | |
download | elfutils-cc2b85c4536f415547981fc4cf176e3fae967acc.tar.gz |
debuginfod: optimize regular expressions in groom()
Check if applying of -I and -X during grooming is enabled
before the regular expressions are matched.
Signed-off-by: Josef Cejka <jcejka@suse.de>
Diffstat (limited to 'debuginfod')
-rw-r--r-- | debuginfod/ChangeLog | 4 | ||||
-rw-r--r-- | debuginfod/debuginfod.cxx | 12 |
2 files changed, 13 insertions, 3 deletions
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index 2ff63e22..a8b5d7f4 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,7 @@ +2022-08-02 Josef Cejka <jcejka@suse.de> + + * debuginfod.cxx (groom): Don't evaluate regex unless needed. + 2022-07-29 Josef Cejka <jcejka@suse.de> * debuginfod.cxx: Create db indexes for fast delete while grooming. diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx index 303ffe00..a089d0bd 100644 --- a/debuginfod/debuginfod.cxx +++ b/debuginfod/debuginfod.cxx @@ -3580,11 +3580,17 @@ void groom() int64_t fileid = sqlite3_column_int64 (files, 1); const char* filename = ((const char*) sqlite3_column_text (files, 2) ?: ""); struct stat s; - bool reg_include = !regexec (&file_include_regex, filename, 0, 0, 0); - bool reg_exclude = !regexec (&file_exclude_regex, filename, 0, 0, 0); + bool regex_file_drop = 0; + + if (regex_groom) + { + bool reg_include = !regexec (&file_include_regex, filename, 0, 0, 0); + bool reg_exclude = !regexec (&file_exclude_regex, filename, 0, 0, 0); + regex_file_drop = reg_exclude && !reg_include; + } rc = stat(filename, &s); - if ( (regex_groom && reg_exclude && !reg_include) || rc < 0 || (mtime != (int64_t) s.st_mtime) ) + if ( regex_file_drop || rc < 0 || (mtime != (int64_t) s.st_mtime) ) { if (verbose > 2) obatched(clog) << "groom: stale file=" << filename << " mtime=" << mtime << endl; |