unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 36190@debbugs.gnu.org
Subject: bug#36190: 27.0.50; `put-text-property' etc. with buffer argument calls current buffer's `after-change-functions'
Date: Thu, 13 Jun 2019 20:57:08 +0000	[thread overview]
Message-ID: <CAOqdjBe-x3bQ0ZjjrOn9oYG2uJi9EAJD=VsXiQhAxtejVR_Ujg@mail.gmail.com> (raw)
In-Reply-To: <83y325xnk0.fsf@gnu.org>

On Thu, Jun 13, 2019 at 8:01 PM Eli Zaretskii <eliz@gnu.org> wrote:
> > From: Pip Cet <pipcet@gmail.com>
> > Date: Thu, 13 Jun 2019 19:42:29 +0000
> > Cc: 36190@debbugs.gnu.org
> >
> > > Not sure I have a clear idea of how you intend to use that additional
> > > argument.  Are you suggesting that we switch to that buffer?
> >
> > Yes:
> >
> > @@ -2183,6 +2184,9 @@ signal_after_change (ptrdiff_t charpos,
> > ptrdiff_t lendel, ptrdiff_t lenins)
> >    if (inhibit_modification_hooks)
> >      return;
> >
> > +  record_unwind_current_buffer ();
> > +  set_buffer_internal (buffer);
>
> Ugh! switching buffers just to run a hook!
>  This will kill performance
> in some cases.

I really don't think it will have a noticeable impact on performance,
but if you can think of a scenario, we could try to fix it.

> We had something similar with JSON parsing a few
> months ago.
> I wish we had a better alternative.

(Such as not calling regular modification hooks for text property changes?)

>  Maybe we should warn
> in the documentation that calling these functions with BUFFER being
> other than the current buffer might hurt performance when
> after-change-functions is non-nil.

It'll hurt performance even when after-change-functions is nil, so
such a warning would be overspecific.

> > As a practical matter, it's hard to change the text property functions
> > to use NULL when passed a nil argument
>
> How is it harder than passing current_buffer?

The code path goes through

  if (NILP (object))
    XSETBUFFER (object, current_buffer);

> It's really a matter of stylistic preferences, but you did ask why...

It was out of genuine interest, because passing NULL to implicitly
specify a default argument is something that people advocate against,
and that C in particular has a history of avoiding (stdout isn't NULL,
and post-VAX NULL isn't an empty string, for example). Thank you for
responding, and I'll change my patch accordingly.





  reply	other threads:[~2019-06-13 20:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 13:48 bug#36190: 27.0.50; `put-text-property' etc. with buffer argument calls current buffer's `after-change-functions' Pip Cet
2019-06-13 16:36 ` Eli Zaretskii
2019-06-13 18:48   ` Pip Cet
2019-06-13 19:05     ` Eli Zaretskii
2019-06-13 19:27       ` Eli Zaretskii
2019-06-13 19:42       ` Pip Cet
2019-06-13 20:01         ` Eli Zaretskii
2019-06-13 20:57           ` Pip Cet [this message]
2019-06-13 21:37             ` Pip Cet
2019-06-14  7:41               ` Eli Zaretskii
2019-06-14 11:14                 ` Pip Cet
2019-06-14 12:10                   ` Eli Zaretskii
2019-06-15 15:14                     ` Pip Cet
2019-06-15 15:23                       ` Eli Zaretskii
2019-06-15 19:27                         ` Pip Cet
2019-07-06  8:08                           ` Eli Zaretskii
2019-07-06 15:27                             ` Pip Cet
2019-07-06 16:22                               ` Eli Zaretskii
2019-06-14  7:36             ` Eli Zaretskii
2019-06-17 11:38               ` Pip Cet
2019-06-17 15:59                 ` Eli Zaretskii
2019-06-18 17:14                   ` Pip Cet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOqdjBe-x3bQ0ZjjrOn9oYG2uJi9EAJD=VsXiQhAxtejVR_Ujg@mail.gmail.com' \
    --to=pipcet@gmail.com \
    --cc=36190@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).