+2004-01-12 Jesper Harder <harder@ifa.au.dk>
+
+ * rfc2047.el (rfc2047-decode-string): Don't cons a string
+ unnecessarily.
+
+ * mm-util.el (mm-replace-chars-in-string): Remove.
+
+ * rfc2047.el (rfc2047-decode): Use mm-subst-char-in-string instead
+ of mm-replace-chars-in-string.
+
+2004-01-11 Jesper Harder <harder@ifa.au.dk>
+
+ * gnus.sum.el (gnus-remove-odd-characters): Don't cons two new
+ strings.
+
+ * mm-util.el (mm-subst-char-in-string): Support inplace.
+
+ * gnus-sum.el (gnus-summary-remove-list-identifiers): Don't cons
+ a new string in every iteration. Use shy groups.
+
2004-01-10 Jesper Harder <harder@ifa.au.dk>
* gnus-start.el (gnus-subscribe-newsgroup, gnus-start-draft-setup)
"Translate STRING into something that doesn't contain weird characters."
(mm-subst-char-in-string
?\r ?\-
- (mm-subst-char-in-string
- ?\n ?\- string)))
+ (mm-subst-char-in-string ?\n ?\- string t) t))
;; This function has to be called with point after the article number
;; on the beginning of the line.
gnus-list-identifiers))
changed subject)
(when regexp
+ (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
(dolist (header gnus-newsgroup-headers)
(setq subject (mail-header-subject header)
changed nil)
- (while (string-match
- (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
- subject)
+ (while (string-match regexp subject)
(setq subject
- (concat (substring subject 0 (match-beginning 2))
+ (concat (substring subject 0 (match-beginning 1))
(substring subject (match-end 0)))
changed t))
- (when (and changed
- (string-match
- "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
- (setq subject
- (concat (substring subject 0 (match-beginning 1))
- (substring subject (match-end 1)))))
(when changed
+ (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
+ (setq subject
+ (concat (substring subject 0 (match-beginning 1))
+ (substring subject (match-end 1)))))
(mail-header-set-subject header subject))))))
(defun gnus-fetch-headers (articles)
mm-mime-mule-charset-alist)
nil t))))
(subst-char-in-string
- . (lambda (from to string) ;; stolen (and renamed) from nnheader.el
- "Replace characters in STRING from FROM to TO."
- (let ((string (substring string 0)) ;Copy string.
+ . (lambda (from to string &optional inplace) ;; stolen (and renamed) from nnheader.el
+ "Replace characters in STRING from FROM to TO.
+ Unless optional argument INPLACE is non-nil, return a new string."
+ (let ((string (if inplace string (copy-sequence string)))
(len (length string))
(idx 0))
;; Replace all occurrences of FROM with TO.
(setq cs c)))
cs))))
-(defsubst mm-replace-chars-in-string (string from to)
- (mm-subst-char-in-string from to string))
-
(eval-and-compile
(defvar mm-emacs-mule (and (not (featurep 'xemacs))
(boundp 'default-enable-multibyte-characters)
mail-parse-charset
(not (eq mail-parse-charset 'us-ascii))
(not (eq mail-parse-charset 'gnus-decoded)))
- (mm-decode-coding-string string mail-parse-charset)
+ ;; `decode-coding-string' in Emacs offers a third optional
+ ;; arg NOCOPY to avoid consing a new string if the decoding
+ ;; is "trivial". Unfortunately it currently doesn't
+ ;; consider anything else than a `nil' coding system
+ ;; trivial.
+ ;; `rfc2047-decode-string' is called multiple times for each
+ ;; article during summary buffer generation, and we really
+ ;; want to avoid unnecessary consing. So we bypass
+ ;; `decode-coding-string' if the string is purely ASCII.
+ (if (and (fboundp 'detect-coding-string)
+ ;; string is purely ASCII
+ (eq (detect-coding-string string t) 'undecided))
+ string
+ (mm-decode-coding-string string mail-parse-charset))
(mm-string-as-multibyte string)))))
(defun rfc2047-parse-and-decode (word)
(rfc2047-pad-base64 string)))
((equal "Q" encoding)
(quoted-printable-decode-string
- (mm-replace-chars-in-string string ?_ ? )))
+ (mm-subst-char-in-string ?_ ? string t)))
(t (error "Invalid encoding: %s" encoding)))
cs))))