emacs-devel
[Top][All Lists]
Advanced

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

Re: Thinking about changed buffers


From: Lars Magne Ingebrigtsen
Subject: Re: Thinking about changed buffers
Date: Mon, 28 Mar 2016 20:51:54 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Lars Magne Ingebrigtsen <address@hidden> writes:

> 1) Speed.

And I had an idea here, too.  :-)  `buffer-modified-p' is today just
this simple integer comparison:

DEFUN ("buffer-modified-p", Fbuffer_modified_p, Sbuffer_modified_p,
[...]
  return BUF_SAVE_MODIFF (buf) < BUF_MODIFF (buf) ? Qt : Qnil;
}

How could it look under a hashey regime?  Pseudoish code coming up:

{
  if (BUF_SAVE_MODIFF (buf) == BUF_MODIFF (buf))
    return Qnil;
  if (BUF_SAVE_HASHED_SIZE (buf) != BUF_HASHED_SIZE (buf))
    return Qt;
  same = string_equal(buffer_hash (buf), buf->save_hash);
  if (! NILP (same))
    buf->text->save_modiff = buf->text->modiff;
  return same;
}

Uhm...  is that correct?  *squints*  Perhaps.

Anyway, if we do it this way (that is, keep the modiff counter around),
we can short circuit the hash calculation like, almost always.  It would
only be necessary (the first time per ... time) the buffer reaches the
same size that it used to be.

That is, it would basically happen in the "insert an 'a' and then delete
the 'a'" case, but very seldom otherwise, so `buffer-modified-p' would
be almost as fast as it usually is.

Now I'm kinda starting to think that this isn't just feasible, but
possible in practice, too.  :-)

I might be totally wrong, though.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

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