unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* The current state of the comment-cache branch
@ 2016-12-23 21:50 Alan Mackenzie
  2016-12-24  1:32 ` Stefan Monnier
                   ` (3 more replies)
  0 siblings, 4 replies; 51+ messages in thread
From: Alan Mackenzie @ 2016-12-23 21:50 UTC (permalink / raw)
  To: emacs-devel

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).



^ permalink raw reply	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2017-01-22  4:28 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-23 21:50 The current state of the comment-cache branch Alan Mackenzie
2016-12-24  1:32 ` Stefan Monnier
2016-12-24  9:07   ` Alan Mackenzie
2016-12-24  1:33 ` Stefan Monnier
2016-12-24  8:40   ` Alan Mackenzie
2016-12-24 20:56   ` Stephen Leake
2016-12-25 15:47     ` Stefan Monnier
2016-12-25 20:41     ` Richard Stallman
2016-12-24  8:02 ` Eli Zaretskii
2016-12-24  8:30   ` Alan Mackenzie
2016-12-24  8:55     ` Eli Zaretskii
2016-12-24  9:42       ` Alan Mackenzie
2016-12-24 11:11         ` Elias Mårtenson
2016-12-24 11:36           ` Alan Mackenzie
2016-12-24 12:00             ` Eli Zaretskii
2016-12-24 21:48               ` Andreas Röhler
     [not found]             ` <CADtN0W+7zHzuoWFrzs6MuonUM74D_dC+yh10rSk+r0nuxgeTBg@mail.gmail.com>
     [not found]               ` <CADtN0WJYXRg=oEBxn3UPjF6RFJG62nG4GpUFaphdkj9Egde_4Q@mail.gmail.com>
2016-12-24 12:21                 ` Elias Mårtenson
2016-12-27 17:55                   ` Alan Mackenzie
2016-12-28 15:36                     ` Eli Zaretskii
2016-12-28 16:42                       ` Alan Mackenzie
2016-12-28 16:45                       ` Nikolaus Rath
2016-12-28 17:09                         ` Eli Zaretskii
2016-12-28 23:58                           ` Nikolaus Rath
2016-12-29  3:43                             ` Eli Zaretskii
2016-12-29 16:56                               ` Nikolaus Rath
2016-12-29 17:46                                 ` Eli Zaretskii
2016-12-29 19:44                                   ` Alan Mackenzie
2016-12-30 10:29                                     ` Andreas Röhler
2017-01-03 17:39                                       ` Stefan Monnier
2017-01-20 18:58                                         ` Andreas Röhler
2017-01-20 21:48                                           ` Stefan Monnier
2017-01-21  9:06                                             ` Andreas Röhler
2017-01-22  4:28                                               ` Stefan Monnier
2016-12-28 17:15                         ` Stefan Monnier
2016-12-29  1:38                           ` Richard Stallman
2016-12-29  2:15                             ` Stefan Monnier
2016-12-24 12:27         ` Eli Zaretskii
2016-12-24 22:19           ` Paul Eggert
2016-12-25 16:07           ` Stefan Monnier
2016-12-25 16:30             ` Eli Zaretskii
2016-12-28  8:37             ` Alan Mackenzie
2016-12-28 17:02               ` Stefan Monnier
2016-12-28 17:10               ` Stefan Monnier
2016-12-27 16:40           ` Alan Mackenzie
2016-12-28 15:35             ` Eli Zaretskii
2016-12-28 16:35               ` Alan Mackenzie
2016-12-24 18:54 ` Richard Stallman
2016-12-27 16:11   ` Alan Mackenzie
2016-12-28  1:40     ` Dmitry Gutov
2016-12-28  7:54       ` Alan Mackenzie
2016-12-29  1:13         ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).