public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] debuginfod: optimize regular expressions in groom()
@ 2022-08-03 14:19 Josef Čejka
  2022-08-03 14:26 ` Frank Ch. Eigler
  0 siblings, 1 reply; 2+ messages in thread
From: Josef Čejka @ 2022-08-03 14:19 UTC (permalink / raw)
  To: elfutils-devel

From 2b377704f46081f2348dfc5650820ac9b5485758 Mon Sep 17 00:00:00 2001
From: Josef Cejka <jcejka@suse.de>
Date: Wed, 3 Aug 2022 13:33:21 +0200
Subject: [PATCH] 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>
---
 debuginfod/debuginfod.cxx | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

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;
-- 
2.35.3




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-03 14:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-03 14:19 [PATCH] debuginfod: optimize regular expressions in groom() Josef Čejka
2022-08-03 14:26 ` Frank Ch. Eigler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).