emacs-devel
[Top][All Lists]
Advanced

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

Re: Case mapping of sharp s


From: Andreas Schwab
Subject: Re: Case mapping of sharp s
Date: Sat, 21 Nov 2009 12:58:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Ulrich Mueller <address@hidden> writes:

> Is that the reason for the backwards search in ERC buffers being
> extremely slow? It may keep Emacs busy for several *minutes*. And it's
> not interruptible with C-g.

Does this patch help?

Andreas.

Index: search.c
===================================================================
RCS file: /sources/emacs/emacs/src/search.c,v
retrieving revision 1.247
diff -u -a -p -r1.247 search.c
--- search.c    21 Nov 2009 11:52:29 -0000      1.247
+++ search.c    21 Nov 2009 11:53:02 -0000
@@ -1609,39 +1609,36 @@ simple_search (n, pat, len, len_byte, tr
        while (1)
          {
            /* Try matching at position POS.  */
-           EMACS_INT this_pos = pos - len;
-           EMACS_INT this_pos_byte;
+           EMACS_INT this_pos = pos;
+           EMACS_INT this_pos_byte = pos_byte;
            int this_len = len;
-           unsigned char *p = pat;
+           unsigned char *p = pat + len_byte;
 
-           if (this_pos < lim || (pos_byte - len_byte) < lim_byte)
+           if (this_pos - len < lim || (pos_byte - len_byte) < lim_byte)
              goto stop;
-           this_pos_byte = CHAR_TO_BYTE (this_pos);
-           match_byte = pos_byte - this_pos_byte;
 
            while (this_len > 0)
              {
-               int charlen, buf_charlen;
+               int charlen;
                int pat_ch, buf_ch;
 
-               pat_ch = STRING_CHAR_AND_LENGTH (p, charlen);
-               buf_ch = STRING_CHAR_AND_LENGTH (BYTE_POS_ADDR (this_pos_byte),
-                                                buf_charlen);
+               DEC_BOTH (this_pos, this_pos_byte);
+               PREV_CHAR_BOUNDARY (p, pat);
+               pat_ch = STRING_CHAR (p);
+               buf_ch = STRING_CHAR (BYTE_POS_ADDR (this_pos_byte));
                TRANSLATE (buf_ch, trt, buf_ch);
 
                if (buf_ch != pat_ch)
                  break;
 
                this_len--;
-               p += charlen;
-               this_pos_byte += buf_charlen;
-               this_pos++;
              }
 
            if (this_len == 0)
              {
-               pos -= len;
-               pos_byte -= match_byte;
+               match_byte = pos_byte - this_pos_byte;
+               pos = this_pos;
+               pos_byte = this_pos_byte;
                break;
              }
 

-- 
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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