emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r109098: Fix bug #11943 with slow red


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109098: Fix bug #11943 with slow redisplay in large paragraphs full of weak characters.
Date: Sun, 15 Jul 2012 17:41:08 +0300
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109098
fixes bug: http://debbugs.gnu.org/11943
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Sun 2012-07-15 17:41:08 +0300
message:
  Fix bug #11943 with slow redisplay in large paragraphs full of weak 
characters.
  
   src/bidi.c (MAX_STRONG_CHAR_SEARCH): New macro.
   (bidi_paragraph_init): Use it to limit search forward for a strong
   directional character in abnormally large paragraphs full of
   neutral or weak characters.
modified:
  src/ChangeLog
  src/bidi.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-07-15 14:22:09 +0000
+++ b/src/ChangeLog     2012-07-15 14:41:08 +0000
@@ -1,3 +1,10 @@
+2012-07-15  Eli Zaretskii  <address@hidden>
+
+       * bidi.c (MAX_STRONG_CHAR_SEARCH): New macro.
+       (bidi_paragraph_init): Use it to limit search forward for a strong
+       directional character in abnormally large paragraphs full of
+       neutral or weak characters.  (Bug#11943)
+
 2012-07-15  Stefano Facchini  <address@hidden>  (tiny change)
 
        * gtkutil.c (xg_create_tool_bar): Apply "primary-toolbar" style to

=== modified file 'src/bidi.c'
--- a/src/bidi.c        2012-07-05 18:35:48 +0000
+++ b/src/bidi.c        2012-07-15 14:41:08 +0000
@@ -1123,6 +1123,12 @@
   return pos_byte;
 }
 
+/* On a 3.4 GHz machine, searching forward for a strong directional
+   character in a long paragraph full of weaks or neutrals takes about
+   1 ms for each 20K characters.  The number below limits each call to
+   bidi_paragraph_init to less than 10 ms even on slow machines.  */
+#define MAX_STRONG_CHAR_SEARCH 100000
+
 /* Determine the base direction, a.k.a. base embedding level, of the
    paragraph we are about to iterate through.  If DIR is either L2R or
    R2L, just use that.  Otherwise, determine the paragraph direction
@@ -1218,6 +1224,8 @@
       /* The following loop is run more than once only if NO_DEFAULT_P
         is non-zero, and only if we are iterating on a buffer.  */
       do {
+       ptrdiff_t pos1;
+
        bytepos = pstartbyte;
        if (!string_p)
          pos = BYTE_TO_CHAR (bytepos);
@@ -1226,11 +1234,15 @@
                              bidi_it->frame_window_p, &ch_len, &nchars);
        type = bidi_get_type (ch, NEUTRAL_DIR);
 
+       pos1 = pos;
        for (pos += nchars, bytepos += ch_len;
-            (bidi_get_category (type) != STRONG)
-              || (bidi_ignore_explicit_marks_for_paragraph_level
-                  && (type == RLE || type == RLO
-                      || type == LRE || type == LRO));
+            ((bidi_get_category (type) != STRONG)
+             || (bidi_ignore_explicit_marks_for_paragraph_level
+                 && (type == RLE || type == RLO
+                     || type == LRE || type == LRO)))
+              /* Stop when searched too far into an abnormally large
+                 paragraph full of weak or neutral characters.  */
+              && pos - pos1 < MAX_STRONG_CHAR_SEARCH;
             type = bidi_get_type (ch, NEUTRAL_DIR))
          {
            if (pos >= end)


reply via email to

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