[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Edebug corrupting point in buffers; we need buffer-point and set-buf
From: |
Alan Mackenzie |
Subject: |
Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps. |
Date: |
Mon, 31 Oct 2022 20:46:12 +0000 |
Hello, Eli.
On Mon, Oct 31, 2022 at 19:55:40 +0200, Eli Zaretskii wrote:
> > Date: Mon, 31 Oct 2022 15:46:07 +0000
> > Cc: emacs-devel@gnu.org
> > From: Alan Mackenzie <acm@muc.de>
> > > I'm not sure performance in a debugger is a reason good enough to add
> > > 2 more primitives. The fact that we didn't need them until now should
> > > tell us something, no?
> > Well, I timed it. With 207 buffers, creating an alist of (buffer .
> > buffere-point) with my new function was 17 times as fast as using
> > with-current-buffer and point.
> 17 times faster doesn't yet tell how important is the speedup, because
> you give no absolute numbers, and they are what's important here.
I think I did. To quote:
> > It's probably moot, though, since the "slow" restoration only took
> > 0.00137 seconds for all 207 buffers.
> > But on the other hand, these two functions feel like they ought to exist.
> > They could save a lot of clumsy programming with swapping the buffer,
> > just to get or set point.
> There's nothing clumsy with what we did, and the fact that we did
> manage without them speaks volumes.
OK.
> > > > +DEFUN ("buffer-point", Fbuffer_point, Sbuffer_point, 1, 1, 0,
> > > > + doc: /* Return the buffer point of BUFFER-OR-NAME.
> > > > +The argument may be a buffer or the name of an existing buffer. */)
> > > > + (Lisp_Object buffer_or_name)
> > > Why not an optional argument to 'point'? And why in buffer.c and not
> > > in editfns.c?
> > I'm not sure what you mean by an optional argument, here.
> I mean (point &optional buffer), of course, what else could I mean?
OK.
> > > > + return (make_fixnum (b->pt));
> > > Please never-ever use b->pt etc. directly. We have BUF_PT and other
> > > macros for that, and for a good reason.
> > BUF_PT and friends work specifically on current_buffer.
> No, they don't:
Apologies. I got that wrong.
> /* Position of point in buffer. */
> INLINE ptrdiff_t
> BUF_PT (struct buffer *buf)
> {
> return (buf == current_buffer ? PT
> : NILP (BVAR (buf, pt_marker)) ? buf->pt
> : marker_position (BVAR (buf, pt_marker)));
> }
> > The whole idea of the new functions is to avoid having to switch
> > buffers.
> We do this from C in a gazillion of places.
OK. I now think these new functions aren't really needed, mainly because
the current way, though much slower, is fast enough. I still think they
would be a neater way of getting/setting a buffer point, but it's not a
big thing.
--
Alan Mackenzie (Nuremberg, Germany).
- Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps., Alan Mackenzie, 2022/10/31
- Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps., Eli Zaretskii, 2022/10/31
- Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps., Alan Mackenzie, 2022/10/31
- Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps., Eli Zaretskii, 2022/10/31
- Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps., Alan Mackenzie, 2022/10/31
- Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps., Stefan Monnier, 2022/10/31
- Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps., Eli Zaretskii, 2022/10/31
- Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps.,
Alan Mackenzie <=
- Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps., Stefan Monnier, 2022/10/31
- Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps., Eli Zaretskii, 2022/10/31
- Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps., Stefan Monnier, 2022/10/31
Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps., Stefan Monnier, 2022/10/31
Re: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps., Alan Mackenzie, 2022/10/31