all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Milan Stanojević" <mstanojevic@janestreet.com>
Cc: 31837@debbugs.gnu.org
Subject: bug#31837: 26.1; replace-buffer-contents doesn't work if buffer has multibyte characters
Date: Tue, 19 Jun 2018 05:30:29 +0300	[thread overview]
Message-ID: <83r2l3se2i.fsf@gnu.org> (raw)
In-Reply-To: <CAArdBwP6n=QgMCRtN-R=XgnMY8-sHUJhYXRi2L6SuREYOQAUsw@mail.gmail.com> (message from Milan Stanojević on Mon, 18 Jun 2018 16:29:41 -0400)

> From: Milan Stanojević <mstanojevic@janestreet.com>
> Date: Mon, 18 Jun 2018 16:29:41 -0400
> Cc: 31837@debbugs.gnu.org
> 
> If we do care about optimizing it, then it is better to check whether
> the buffer actually contains multibyte characters (I guess with
> BUF_Z(buf) == BUF_Z_BYTE(buf)) than using enable_multibyte_characters
> since the the former would catch strictly more cases when we don't
> need charpos to bytepos conversion.

No, testing BUF_Z vs BUF_Z_BYTE cannot possibly catch more cases,
because multibyte characters cannot happen in a buffer whose
enable_multibyte_characters is reset, and any unibyte buffer's Z value
is trivially equal to its Z_BYTE value.

> Also, it occurs to me, the check shouldn't be done in
> buffer_chars_equal, since the same check would be done multiple times
> for a single character (for every comparison of that character), it
> should be done once and the result stored in ctx before calling
> compareseq.

Something to consider if further optimization is needed.





  reply	other threads:[~2018-06-19  2:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-14 21:34 bug#31837: 26.1; replace-buffer-contents doesn't work if buffer has multibyte characters Milan Stanojević
2018-06-15  8:34 ` Eli Zaretskii
2018-06-18 17:44   ` Milan Stanojević
2018-06-18 18:16     ` Eli Zaretskii
2018-06-18 20:29       ` Milan Stanojević
2018-06-19  2:30         ` Eli Zaretskii [this message]
2018-07-01 17:32   ` Philipp Stephani

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

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

  git send-email \
    --in-reply-to=83r2l3se2i.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=31837@debbugs.gnu.org \
    --cc=mstanojevic@janestreet.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.