octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #57064] Severe slowdown of regexp matching


From: Pantxo Diribarne
Subject: [Octave-bug-tracker] [bug #57064] Severe slowdown of regexp matching
Date: Thu, 17 Oct 2019 09:21:54 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0

Update of bug #57064 (project octave):

              Item Group:        Unexpected Error => Regression             
                  Status:                    None => Confirmed              
                 Summary: regexp hangs in infinite loop => Severe slowdown of
regexp matching

    _______________________________________________________

Follow-up Comment #6:

After earching for "pcre utf8 slow" I've read that if the string can be safely
assumed to be utf8, then one can by-pass a time consuming check using the
PCRE_NO_UTF8_CHECK option. With this option tst.m returns in 1 s while it
takes 51 s without it.

I used the following diff:


diff -r 25479159213b liboctave/util/lo-regexp.cc
--- a/liboctave/util/lo-regexp.cc       Wed Oct 16 14:35:03 2019 -0700
+++ b/liboctave/util/lo-regexp.cc       Thu Oct 17 15:19:09 2019 +0200
@@ -280,7 +280,7 @@
 
         int matches = pcre_exec (re, nullptr, buffer.c_str (),
                                  buffer.length (), idx,
-                                 (idx ? PCRE_NOTBOL : 0),
+                                 PCRE_NO_UTF8_CHECK | (idx ? PCRE_NOTBOL :
0),
                                  ovector, (subpatterns+1)*3);
 
         if (matches == PCRE_ERROR_MATCHLIMIT)
@@ -307,7 +307,8 @@
                 pe.match_limit *= 10;
                 matches = pcre_exec (re, &pe, buffer.c_str (),
                                      buffer.length (), idx,
-                                     (idx ? PCRE_NOTBOL : 0),
+                                     PCRE_NO_UTF8_CHECK
+                                     | (idx ? PCRE_NOTBOL : 0),
                                      ovector, (subpatterns+1)*3);
               }
           }



Updating the title, item group and status

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57064>

_______________________________________________
  Message posté via Savannah
  https://savannah.gnu.org/




reply via email to

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