Subject: Re: bug#34765: 26.1; with-temp-buffer should not run buffer-list-update-hook

From: Eli Zaretskii <[email-masked]>
Date: Wed, 22 May 2019 13:06:48 +0300

> Cc: [email-masked], [email-masked], [email-masked],
>  [email-masked]
> From: martin rudalics <[email-masked]>
> Date: Wed, 22 May 2019 10:32:39 +0200
> 
>  >> I have not managed to understand the Vcode_conversion_workbuf_name
>  >> vs Vcode_conversion_reused_workbuf rigmarole yet.
>  >
>  > The latter is a fixed buffer, created once and never killed.  So the
>  > buffer hooks never run for it, and never affect Emacs.  By contrast,
>  > the former is a buffer created when the reused buffer is busy and
>  > cannot be reused.  We then kill Vcode_conversion_workbuf_name when we
>  > no longer need it.  Thus, buffer hooks run for these work buffers all
>  > the time, and for a code-conversion intensive code they could slow
>  > down Emacs, specially if the list of buffer hooks is long.
> 
> Thanks, I hope I understand it now.  Could you pretty please add the
> (instructive for me) "a buffer created when the reused buffer is busy
> and cannot be reused" somewhere to the comments maybe together with a
> reference to reused_workbuf_in_use.

Not sure where you want to add this.  coding.c already says:

  /* Name (or base name) of work buffer for code conversion.  */
  Lisp_Object Vcode_conversion_workbuf_name;

  /* A working buffer used by the top level conversion.  Once it is
     created, it is never destroyed.  It has the name
     Vcode_conversion_workbuf_name.  The other working buffers are
     destroyed after the use is finished, and their names are modified
     versions of Vcode_conversion_workbuf_name.  */
  static Lisp_Object Vcode_conversion_reused_workbuf;

  /* True iff Vcode_conversion_reused_workbuf is already in use.  */
  static bool reused_workbuf_in_use;

is that what you wanted to see?

> Hopefully this also means that we can use _something like_
> Fgenerate_new_buffer to replace both instances of Fget_buffer_create
> in code_conversion_restore.

You mean code_conversion_save, I presume.

One of those calls to Fget_buffer_create shouldn't generate a new
name, though.  It should always use a fixed name.