From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/64520 Path: news.gmane.org!not-for-mail From: Reiner Steib Newsgroups: gmane.emacs.gnus.general Subject: with-case-table in nnfolder.el Date: Sun, 15 Apr 2007 12:19:09 +0200 Message-ID: Reply-To: Reiner Steib NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1176632522 8424 80.91.229.12 (15 Apr 2007 10:22:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 15 Apr 2007 10:22:02 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M13031@lists.math.uh.edu Sun Apr 15 12:21:56 2007 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hd1rn-0001FE-5n for ding-account@gmane.org; Sun, 15 Apr 2007 12:21:55 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1Hd1qS-0007Jz-GR; Sun, 15 Apr 2007 05:20:32 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1Hd1qQ-0007JY-0e for ding@lists.math.uh.edu; Sun, 15 Apr 2007 05:20:30 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.63) (envelope-from ) id 1Hd1qJ-0001U1-1L for ding@lists.math.uh.edu; Sun, 15 Apr 2007 05:20:29 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Hd1qH-0007Kw-00 for ; Sun, 15 Apr 2007 12:20:21 +0200 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Hd1q9-0004A4-Ge for ding@gnus.org; Sun, 15 Apr 2007 12:20:13 +0200 Original-Received: from bridgekeeper.physik.uni-ulm.de ([134.60.10.123]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 15 Apr 2007 12:20:13 +0200 Original-Received: from Reiner.Steib by bridgekeeper.physik.uni-ulm.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 15 Apr 2007 12:20:13 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: ding@gnus.org Original-Lines: 215 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: bridgekeeper.physik.uni-ulm.de X-Face: .*T0'iU(sujq_j9\J>-d4fg;N/1++U#U$_5ii6k.=|"-n'?5O:Hyz&wi'-!I~,}7~GgT=0S /&-R5sbkNy5+Xo1y{Tw2KKxi@Xh"g@]Qc|.U<*]WDd)qvGowFDvfU1F]{EDho:7P0@|oOD=Bc{K4?> WP68K[Mx:}=`ZT'6g4'f+g?;`vri2!)xGy}3:=l'(/Cea0l4lo^H5#@/Z3ev Mail-Copies-To: nobody User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.97 (gnu/linux) Cancel-Lock: sha1:lGp0o08n/KpDQTrro0Rj7uJ/Zsc= X-Spam-Score: -2.6 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:64520 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi, the case conversion in Emacs 22 makes large nnfolder groups very slow if the user has a Turkish locale because of the Turkish case conversion of `i' and `I' into `İ' and `ı' (cf. `turkish-case-conversion-enable'). [ See http://thread.gmane.org/gmane.emacs.devel/68859/focus=64496 http://thread.gmane.org/gmane.emacs.gnus.general/63925/focus=63979 for more information. ] The following patch should fix this slowness. But I don't use nnfolder myself and I don't have much time for testing, so I hesitate to install it (even in the trunk). Could someone please review the patch and/or test it, please? To change your locale to Turkish temporarily, you can start Emacs using "LC_CTYPE=tr_TR emacs -f gnus". But also testing it with your usual locale if you are using nnfolder would be useful. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=rs-nnfolder-search-marker-2007-04-15.patch --- nnfolder.el 26 Jan 2007 20:41:00 +0100 7.17 +++ nnfolder.el 15 Apr 2007 12:14:43 +0200 @@ -104,6 +104,37 @@ (defconst nnfolder-article-marker "X-Gnus-Article-Number: " "String used to demarcate what the article number for a message is.") +;; Make sure we're using the standard case table. In a Turkish locale, the +;; "i" in "X-Gnus-Article-Number: " (cf. `turkish-case-conversion-enable') +;; makes parsing large nnfolder groups very slow. +;; ,----[ http://thread.gmane.org/gmane.emacs.gnus.general/63925/focus=63979 ] +;; | Subject: Slow operations on buffers of tens of megabytes +;; | Newsgroups: gmane.emacs.pretest.bugs,gmane.emacs.gnus.general +;; | Date: 2006-11-13 +;; `---- +(defun nnfolder-search (&optional function string &rest args) + "Search for `nnfolder-article-marker' using the standard case table. +FUNCTION is used for searching. If STRING is given, it's used +instead of `nnfolder-article-marker'. The remaining ARGS are +passed to the FUNCTION." + (setq function (cond ((fboundp function) + function) + (function + 'search-backward) + (t + 'search-forward))) + (unless string + (setq string (concat "\n" nnfolder-article-marker))) + (if (and (fboundp 'with-case-table) + (boundp 'ascii-case-table)) + ;; Emacs 22+ + (with-case-table ascii-case-table + (apply function string)) + ;; In Emacs 21 (and XEmacs) `with-case-table' and `ascii-case-table' are + ;; not available, but no wrapping is required because those Emacsen don't + ;; convert "i" specialy even in a Turkish locale. + (apply function string))) + (defvoo nnfolder-current-group nil) (defvoo nnfolder-current-buffer nil) (defvoo nnfolder-status-string "") @@ -198,8 +229,7 @@ ;; as caused by active file bogosity. (cond ((bobp)) - ((search-backward (concat "\n" nnfolder-article-marker) - nil t) + ((nnfolder-search 'search-backward nil nil t) (goto-char (match-end 0)) (setq num (string-to-number (buffer-substring @@ -208,8 +238,7 @@ (< num article))) ;; Check that we are before an article with a ;; higher number. - (search-forward (concat "\n" nnfolder-article-marker) - nil t) + (nnfolder-search 'search-forward nil nil t) (progn (setq num (string-to-number (buffer-substring @@ -284,8 +313,7 @@ (cons nnfolder-current-group article) (goto-char (point-min)) (cons nnfolder-current-group - (if (search-forward (concat "\n" nnfolder-article-marker) - nil t) + (if (nnfolder-search 'search-forward nil nil t) (string-to-number (buffer-substring (point) (point-at-eol))) -1)))))))) @@ -405,10 +433,9 @@ (when nnfolder-current-buffer (set-buffer nnfolder-current-buffer) (goto-char (point-min)) - (let ((marker (concat "\n" nnfolder-article-marker)) - (number "[0-9]+") + (let ((number "[0-9]+") numbers) - (while (and (search-forward marker nil t) + (while (and (nnfolder-search 'search-forward nil nil t) (re-search-forward number nil t)) (let ((newnum (string-to-number (match-string 0)))) (if (nnmail-within-headers-p) @@ -436,8 +463,7 @@ (while (and maybe-expirable is-old) (goto-char (point-min)) (when (and (nnfolder-goto-article (car maybe-expirable)) - (search-forward (concat "\n" nnfolder-article-marker) - nil t)) + (nnfolder-search 'search-forward nil nil t)) (forward-sexp) (when (setq is-old (nnmail-expired-article-p @@ -480,8 +506,7 @@ (erase-buffer) (insert-buffer-substring nntp-server-buffer) (goto-char (point-min)) - (while (re-search-forward - (concat "^" nnfolder-article-marker) + (while (nnfolder-search 're-search-forward nil (save-excursion (and (search-forward "\n\n" nil t) (point))) t) (gnus-delete-line)) @@ -523,7 +548,9 @@ (if (search-forward "\n\n" nil t) (forward-line -1) (goto-char (point-max))) - (while (re-search-backward (concat "^" nnfolder-article-marker) nil t) + (while (nnfolder-search 're-search-backward + (concat "^" nnfolder-article-marker) + nil t) (delete-region (point) (progn (forward-line 1) (point)))) (when nnmail-cache-accepted-message-ids (nnmail-cache-insert (nnmail-fetch-field "message-id") @@ -642,13 +669,12 @@ (defun nnfolder-adjust-min-active (group) ;; Find the lowest active article in this group. (let* ((active (cadr (assoc group nnfolder-group-alist))) - (marker (concat "\n" nnfolder-article-marker)) (number "[0-9]+") (activemin (cdr active))) (save-excursion (set-buffer nnfolder-current-buffer) (goto-char (point-min)) - (while (and (search-forward marker nil t) + (while (and (nnfolder-search 'search-forward nil nil t) (re-search-forward number nil t)) (let ((newnum (string-to-number (match-string 0)))) (if (nnmail-within-headers-p) @@ -788,7 +814,7 @@ (if (search-forward "\n\n" nil t) (forward-line -1) (goto-char (point-max))) - (while (search-backward (concat "\n" nnfolder-article-marker) nil t) + (while (nnfolder-search 'search-backward nil nil t) (delete-region (1+ (point)) (progn (forward-line 2) (point)))) ;; Insert the new newsgroup marker. @@ -894,7 +920,6 @@ (nnmail-activate 'nnfolder) ;; Read in the file. (let ((delim "^From ") - (marker (concat "\n" nnfolder-article-marker)) (number "[0-9]+") (active (or (cadr (assoc group nnfolder-group-alist)) (cons 1 0))) @@ -928,7 +953,7 @@ (when (or nnfolder-ignore-active-file novbuf (< maxid 2)) - (while (and (search-forward marker nil t) + (while (and (nnfolder-search 'search-forward nil nil t) (looking-at number)) (setq newnum (string-to-number (match-string 0))) (when (nnmail-within-headers-p) @@ -959,7 +984,7 @@ (when (not (or nnfolder-distrust-mbox (< maxid 2))) (goto-char (point-max)) - (unless (re-search-backward marker nil t) + (unless (nnfolder-search 're-search-backward nil nil t) (goto-char (point-min))) ;;(when (nnmail-search-unix-mail-delim) ;; (goto-char (point-min))) @@ -982,7 +1007,7 @@ (point) (point-max))) (goto-char start) - (when (not (search-forward marker end t)) + (when (not (nnfolder-search 'search-forward nil end t)) (narrow-to-region start end) (nnmail-insert-lines) (nnfolder-insert-newsgroup-line --=-=-= Bye, Reiner. -- ,,, (o o) ---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/ --=-=-=--