grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v3.3-34-gbe9224d


From: Jim Meyering
Subject: grep branch, master, updated. v3.3-34-gbe9224d
Date: Thu, 19 Dec 2019 10:21:32 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  be9224d9719633674d92b1f2eaed4729dba19eb9 (commit)
      from  0cd76e7aee143c494c9c7b5abb59dfd635df108e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=be9224d9719633674d92b1f2eaed4729dba19eb9


commit be9224d9719633674d92b1f2eaed4729dba19eb9
Author: Norihiro Tanaka <address@hidden>
Date:   Sun Jan 13 07:53:32 2019 +0900

    grep: speed up multiple word matching
    
    grep uses its KWset matcher for multiple word matching, but that is
    very slow when most of the parts matched to a pattern are not words.
    So, if the first match to a pattern is not a word, use the grep matcher
    to match for its line.
    
    Note that when START_PTR is set, the grep matcher uses the regex matcher
    which is very slow to match words.  Therefore, we use the grep matcher
    when only START_PTR is NULL.
    
    * src/kwsearch.c (Fexecute): If an initial match is incomplete because
    not on a word boundary, use the grep matcher to find a matching line.

diff --git a/src/kwsearch.c b/src/kwsearch.c
index f121816..7644350 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -250,6 +250,23 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t 
*match_size,
                 else
                   goto success;
               }
+            if (!start_ptr && !localeinfo.multibyte)
+              {
+                if (! kwsearch->re)
+                  {
+                    fgrep_to_grep_pattern (&kwsearch->pattern, 
&kwsearch->size);
+                    kwsearch->re = GEAcompile (kwsearch->pattern,
+                                               kwsearch->size,
+                                               RE_SYNTAX_GREP);
+                  }
+                end = memchr (beg + len, eol, (buf + size) - (beg + len));
+                end = end ? end + 1 : buf + size;
+                if (EGexecute (kwsearch->re, beg, end - beg, match_size, NULL)
+                    != (size_t) -1)
+                  goto success_match_words;
+                beg = end - 1;
+                break;
+              }
             if (!len)
               break;
             offset = kwsexec (kwset, beg, --len, &kwsmatch, true);
@@ -270,6 +287,7 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t 
*match_size,
  success:
   end = memchr (beg + len, eol, (buf + size) - (beg + len));
   end = end ? end + 1 : buf + size;
+ success_match_words:
   beg = memrchr (buf, eol, beg - buf);
   beg = beg ? beg + 1 : buf;
   len = end - beg;

-----------------------------------------------------------------------

Summary of changes:
 src/kwsearch.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]