(gnus-remove-text-with-property): Make it slightly fast.
authorKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 10 Jun 2004 06:38:02 +0000 (06:38 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 10 Jun 2004 06:38:02 +0000 (06:38 +0000)
lisp/ChangeLog
lisp/gnus-util.el

index b9ccbe7..80c3b9e 100644 (file)
@@ -1,5 +1,8 @@
 2004-06-10  Katsumi Yamaoka  <yamaoka@jpl.org>
 
+       * gnus-util.el (gnus-remove-text-with-property): Make it slightly
+       fast.
+
        * gnus-ems.el (gnus-remove-image): Don't use
        message-text-with-property; remove only the image found first.
 
index 99b487b..e0e73e5 100644 (file)
@@ -214,12 +214,15 @@ is slower."
 
 (defun gnus-remove-text-with-property (prop)
   "Delete all text in the current buffer with text property PROP."
-  (save-excursion
-    (goto-char (point-min))
-    (while (not (eobp))
-      (while (get-text-property (point) prop)
-       (delete-char 1))
-      (goto-char (next-single-property-change (point) prop nil (point-max))))))
+  (let ((start (point-min))
+       end)
+    (unless (get-text-property start prop)
+      (setq start (next-single-property-change start prop)))
+    (while start
+      (setq end (text-property-any start (point-max) prop nil))
+      (delete-region start (or end (point-max)))
+      (setq start (when end
+                   (next-single-property-change start prop))))))
 
 (defun gnus-newsgroup-directory-form (newsgroup)
   "Make hierarchical directory name from NEWSGROUP name."