public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "Josef Čejka" <jcejka@suse.de>
To: "elfutils-devel@sourceware.org" <elfutils-devel@sourceware.org>
Subject: [PATCH] debuginfod: optimize regular expressions in groom()
Date: Wed, 03 Aug 2022 16:19:28 +0200	[thread overview]
Message-ID: <2841021.SvYEEZNnvj@dhcp107> (raw)

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




             reply	other threads:[~2022-08-03 14:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03 14:19 Josef Čejka [this message]
2022-08-03 14:26 ` Frank Ch. Eigler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2841021.SvYEEZNnvj@dhcp107 \
    --to=jcejka@suse.de \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).