emacs-diffs
[Top][All Lists]
Advanced

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

master f189e5d: Don't generate useless range table entries for ASCII cha


From: Mattias Engdegård
Subject: master f189e5d: Don't generate useless range table entries for ASCII chars
Date: Tue, 17 Mar 2020 12:32:17 -0400 (EDT)

branch: master
commit f189e5dc1020db9b41e77488d6290d6e7f032b13
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Don't generate useless range table entries for ASCII chars
    
    In multibyte regexps, each ASCII char or range in a character
    alternative produces a nonsense range table entry in addition to the
    correct bits in the ASCII bitmap.  Those entries do not match anything
    but waste space and time.
    
    * src/regex-emacs.c (regex_compile): Don't generate reversed intervals.
---
 src/regex-emacs.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/regex-emacs.c b/src/regex-emacs.c
index 694431c..0ae004e 100644
--- a/src/regex-emacs.c
+++ b/src/regex-emacs.c
@@ -2113,17 +2113,20 @@ regex_compile (re_char *pattern, ptrdiff_t size,
                        if (CHAR_BYTE8_P (c1))
                          c = BYTE8_TO_CHAR (128);
                      }
-                   if (CHAR_BYTE8_P (c))
-                     {
-                       c = CHAR_TO_BYTE8 (c);
-                       c1 = CHAR_TO_BYTE8 (c1);
-                       for (; c <= c1; c++)
-                         SET_LIST_BIT (c);
-                     }
-                   else if (multibyte)
-                     SETUP_MULTIBYTE_RANGE (range_table_work, c, c1);
-                   else
-                     SETUP_UNIBYTE_RANGE (range_table_work, c, c1);
+                    if (c <= c1)
+                      {
+                        if (CHAR_BYTE8_P (c))
+                          {
+                            c = CHAR_TO_BYTE8 (c);
+                            c1 = CHAR_TO_BYTE8 (c1);
+                            for (; c <= c1; c++)
+                              SET_LIST_BIT (c);
+                          }
+                        else if (multibyte)
+                          SETUP_MULTIBYTE_RANGE (range_table_work, c, c1);
+                        else
+                          SETUP_UNIBYTE_RANGE (range_table_work, c, c1);
+                      }
                  }
              }
 



reply via email to

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