grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.6.3-65-g696adde


From: Paolo Bonzini
Subject: grep branch, master, updated. v2.6.3-65-g696adde
Date: Thu, 06 May 2010 07:53:15 +0000

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  696adde5e36702812cd0c71ba926bd9178d9f10c (commit)
      from  9d1ba48cb7d7d1ed0aeecb2bfe54fc2fde3e9933 (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=696adde5e36702812cd0c71ba926bd9178d9f10c


commit 696adde5e36702812cd0c71ba926bd9178d9f10c
Author: Paolo Bonzini <address@hidden>
Date:   Tue May 4 17:59:50 2010 +0200

    dfa: speed up [[:digit:]] and [[:xdigit:]]
    
    There's no "multibyte pain" in these two classes, since POSIX
    and ISO C99 mandate their contents.
    
    Time for "./grep -x '[[:digit:]]' /usr/share/dict/linux.words"
    Before: 1.5s, after: 0.07s.  (sed manages only 0.5s).
    
    * src/dfa.c (predicates): Declare struct dfa_ctype separately
    from definition.  Add sb_only.
    (find_pred): Return const struct dfa_ctype *.
    (parse_bracket_exp): Return const struct dfa_ctype *.  Do
    not fill MBCSET for sb_only character types.

diff --git a/src/dfa.c b/src/dfa.c
index afcb55b..5984a20 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -709,26 +709,29 @@ typedef int predicate (int);
 /* The following list maps the names of the Posix named character classes
    to predicate functions that determine whether a given character is in
    the class.  The leading [ has already been eaten by the lexical analyzer. */
-static struct {
+struct dfa_ctype {
   const char *name;
-  predicate *pred;
-} const prednames[] = {
-  { "alpha", isalpha },
-  { "upper", isupper },
-  { "lower", islower },
-  { "digit", isdigit },
-  { "xdigit", isxdigit },
-  { "space", isspace },
-  { "punct", ispunct },
-  { "alnum", isalnum },
-  { "print", isprint },
-  { "graph", isgraph },
-  { "cntrl", iscntrl },
-  { "blank", isblank },
-  { NULL, NULL }
+  predicate *func;
+  bool single_byte_only;
 };
 
-static predicate *
+static const struct dfa_ctype prednames[] = {
+  { "alpha", isalpha, false },
+  { "upper", isupper, false },
+  { "lower", islower, false },
+  { "digit", isdigit, true },
+  { "xdigit", isxdigit, true },
+  { "space", isspace, false },
+  { "punct", ispunct, false },
+  { "alnum", isalnum, false },
+  { "print", isprint, false },
+  { "graph", isgraph, false },
+  { "cntrl", iscntrl, false },
+  { "blank", isblank, false },
+  { NULL, NULL, false }
+};
+
+static const struct dfa_ctype *
 find_pred (const char *str)
 {
   unsigned int i;
@@ -736,7 +739,7 @@ find_pred (const char *str)
     if (STREQ (str, prednames[i].name))
       break;
 
-  return prednames[i].pred;
+  return &prednames[i];
 }
 
 /* Multibyte character handling sub-routine for lex.
@@ -833,8 +836,12 @@ parse_bracket_exp (void)
                                      || STREQ  (str, "lower"))
                                        ? "alpha"
                                        : str);
+                  const struct dfa_ctype *pred = find_pred (class);
+                  if (!pred)
+                    dfaerror(_("invalid character class"));
+
 #if MBS_SUPPORT
-                  if (MB_CUR_MAX > 1)
+                  if (MB_CUR_MAX > 1 && !pred->single_byte_only)
                     {
                       /* Store the character class as wctype_t.  */
                       wctype_t wt = wctype (class);
@@ -848,14 +855,9 @@ parse_bracket_exp (void)
                     }
 #endif
 
-                  {
-                    predicate *pred = find_pred (class);
-                    if (!pred)
-                      dfaerror(_("invalid character class"));
-                    for (c2 = 0; c2 < NOTCHAR; ++c2)
-                      if ((*pred)(c2))
-                        setbit_case_fold (c2, ccl);
-                  }
+                  for (c2 = 0; c2 < NOTCHAR; ++c2)
+                    if (pred->func(c2))
+                      setbit_case_fold (c2, ccl);
                 }
 
 #if MBS_SUPPORT

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

Summary of changes:
 src/dfa.c |   56 +++++++++++++++++++++++++++++---------------------------
 1 files changed, 29 insertions(+), 27 deletions(-)


hooks/post-receive
-- 
grep




reply via email to

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