From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Werner LEMBERG Newsgroups: gmane.emacs.devel Subject: Re: `make-overlay' very slow Date: Sat, 11 Apr 2009 08:11:50 +0200 (CEST) Message-ID: <20090411.081150.169736792.wl@gnu.org> References: <20090410.235059.24212167.wl@gnu.org> <20090411.004248.247201382.wl@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Sat_Apr_11_08_11_50_2009_949)--" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1239434536 16956 80.91.229.12 (11 Apr 2009 07:22:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 11 Apr 2009 07:22:16 +0000 (UTC) Cc: acm@muc.de, schwab@linux-m68k.org, emacs-devel@gnu.org To: monnier@iro.umontreal.ca Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 11 09:23:35 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LsXYp-00012F-V2 for ged-emacs-devel@m.gmane.org; Sat, 11 Apr 2009 09:23:32 +0200 Original-Received: from localhost ([127.0.0.1]:48632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LsXXR-0005KS-7Z for ged-emacs-devel@m.gmane.org; Sat, 11 Apr 2009 03:22:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LsXWv-0004mN-1R for emacs-devel@gnu.org; Sat, 11 Apr 2009 03:21:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LsXWp-0004hP-Fv for emacs-devel@gnu.org; Sat, 11 Apr 2009 03:21:31 -0400 Original-Received: from [199.232.76.173] (port=34360 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LsXWp-0004h8-2l for emacs-devel@gnu.org; Sat, 11 Apr 2009 03:21:27 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]:53666) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1LsXWo-0002en-H0 for emacs-devel@gnu.org; Sat, 11 Apr 2009 03:21:26 -0400 Original-Received: (qmail invoked by alias); 11 Apr 2009 07:14:44 -0000 Original-Received: from 77-20-101-114-dynip.superkabel.de (EHLO localhost) [77.20.101.114] by mail.gmx.net (mp058) with SMTP; 11 Apr 2009 09:14:44 +0200 X-Authenticated: #54312696 X-Provags-ID: V01U2FsdGVkX1/lp9pFkz3lexjEa975rpArw4Ql272/2p0I5hb01l iqJk46D3PBFtdW In-Reply-To: X-Mailer: Mew version 6.2.50 on Emacs 22.3.1 / Mule 5.0 (SAKAKI) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.74,0.63 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:110203 Archived-At: ----Next_Part(Sat_Apr_11_08_11_50_2009_949)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit > overlays have a poor algorithmic behavior (many operations take a > time proportional to the number of overlays in the buffer). Better > use text-properties (which are implemented with a tree and should > provide something closer to O(log N) complexity instead). I did that (see attachment for reference), and it really works at a reasonable speed. However, it is the completely wrong concept since it sets the `modified' flag and stores undo information, and it fails with modes which use the `invisible' and `intangible' properties. So here's my item to the Emacs wishlist: Improve speed of (make-overlay) and related functions to be as fast as setting text properties. Werner ----Next_Part(Sat_Apr_11_08_11_50_2009_949)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="line-invisible-text-properties.el" (defun make-lines-invisible (regexp &optional arg) "Make all lines matching a regexp invisible and intangible. With a prefix arg, make them visible again. It is not necessary that REGEXP matches the whole line; if a hit is found, the affected line gets automatically selected. This function affects the whole buffer. Note that this function modifies the `invisible' and `intangible' text properties; it may thus interfere with modes which use them. Due to implementation restrictions in current Emacs versions it is not possible to use overlays -- which would avoid text property modifications -- without becoming unbearably slow for large buffers with many matches." (interactive "MRegexp: \nP") (save-excursion (cond (arg (let ((next-pos (point-min))) (while (setq next-pos (text-property-any next-pos (point-max) 'make-lines-invisible t)) (goto-char next-pos) (setq next-pos (or (next-single-property-change (point) 'make-lines-invisible) (point-max))) (remove-list-of-text-properties (point) next-pos '(make-lines-invisible invisible intangible))))) (t (goto-char (point-min)) (while (re-search-forward regexp nil t) (add-text-properties (line-beginning-position) (1+ (line-end-position)) ; handle \n '(make-lines-invisible t invisible t intangible t)) (goto-char (line-end-position))))))) (global-set-key "\C-cz" 'make-lines-invisible) ----Next_Part(Sat_Apr_11_08_11_50_2009_949)----