emacs-devel
[Top][All Lists]
Advanced

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

The current state of the comment-cache branch


From: Alan Mackenzie
Subject: The current state of the comment-cache branch
Date: Fri, 23 Dec 2016 21:50:56 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

Hello, Emacs.

I have enhanced the comment-cache branch over its state in March 2016.
In particular, it now handles set-syntax-table and modify-syntax-entry.

This branch implements an alternative, superior, method of scanning
comments which supersedes that currently in syntax.c.  It was created to
solve (as opposed to working around) the problem that gave rise to bug
#22884 "25.0.92; C/l Mode editing takes waaaayy too long", raised by Paul
Eggert on 2016-03-02.  That problem is the treating of parens at column
zero, even inside comments, as defun starts.

comment-cache does (forward_comment -1) by reading a @dfn{literal cache}
implemented in text properties which records the string/comment state
throughout the buffer, and moving back to the beginning of the comment as
recorded in this cache.

The cache is trimmed on any buffer change.  It is also trimmed when
(i) a _relevant_ syntax-table text property is applied or removed (even
  when change hooks are disabled);
(ii) set-syntax-table is called, but only when the current and new syntax
  tables parse literals differently.
(iii) an element of the current syntax table which is relevant to literal
  parsing is changed (by modify-syntax-entry).  In this case the literal
  cache of all buffers currently using the syntax table are trimmed.

comment-cache does not impose any noticeable run-time overhead.  Using my
favourite time tool, `time-scroll', which scrolls through a buffer
displaying it at each step I get the following timings for xdisp.c:

                   First forward run     Backwards     Second forward run

master:                 34.100s            36.050s         34.575s 

comment-cache:          30.110s            32.275s         34.990s

.  For reference, here is the source for time-scroll:

#########################################################################
(defmacro time-it (&rest forms)
  "Time the running of a sequence of forms using `float-time'.
Call like this: \"M-: (time-it (foo ...) (bar ...) ...)\"."
  `(let ((start (float-time)))
    ,@forms
    (- (float-time) start)))

(defun time-scroll (&optional arg)
  (interactive "P")
  (message "%s"
           (time-it
            (condition-case nil
                (while t
                  (if arg (scroll-down) (scroll-up))
                  (sit-for 0))
              (error nil)))))
#########################################################################

.  Between successive runs, you should move point to BOB, type a space
and then erase it, to clear the font-lock cache.  Scrolling forward is
(time-scroll).  Backward is (time-scroll t).

I would like the comment-cache code to be merged into master soon.

Comments?

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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