emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-26 0dce5e5: Speed up 'replace-buffer-contents' some


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-26 0dce5e5: Speed up 'replace-buffer-contents' some more
Date: Tue, 3 Jul 2018 15:17:41 -0400 (EDT)

branch: emacs-26
commit 0dce5e59206db7bd0b9cd43ae712272105300ae4
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Speed up 'replace-buffer-contents' some more
    
    * src/editfns.c (EXTRA_CONTEXT_FIELDS): New members beg_a and beg_b.
    (Freplace_buffer_contents): Set up ctx.beg_a and ctx.beg_b.
    (buffer_chars_equal): Use ctx->beg_a and ctx->beg_b instead of
    calling BUF_BEGV, which is expensive.  This speeds up the recipe
    in bug#31888 by 30%.
---
 src/editfns.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/editfns.c b/src/editfns.c
index 9002211..d1a6bfb 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3127,6 +3127,9 @@ static unsigned short rbc_quitcounter;
   /* Buffers to compare.  */                    \
   struct buffer *buffer_a;                      \
   struct buffer *buffer_b;                      \
+  /* BEGV of each buffer */                    \
+  ptrdiff_t beg_a;                             \
+  ptrdiff_t beg_b;                             \
   /* Whether each buffer is unibyte/plain-ASCII or not.  */ \
   bool a_unibyte;                              \
   bool b_unibyte;                              \
@@ -3208,6 +3211,8 @@ differences between the two buffers.  */)
   struct context ctx = {
     .buffer_a = a,
     .buffer_b = b,
+    .beg_a = min_a,
+    .beg_b = min_b,
     .a_unibyte = BUF_ZV (a) == BUF_ZV_BYTE (a),
     .b_unibyte = BUF_ZV (b) == BUF_ZV_BYTE (b),
     .deletions = SAFE_ALLOCA (del_bytes),
@@ -3349,8 +3354,8 @@ static bool
 buffer_chars_equal (struct context *ctx,
                     ptrdiff_t pos_a, ptrdiff_t pos_b)
 {
-  pos_a += BUF_BEGV (ctx->buffer_a);
-  pos_b += BUF_BEGV (ctx->buffer_b);
+  pos_a += ctx->beg_a;
+  pos_b += ctx->beg_b;
 
   /* Allow the user to escape out of a slow compareseq call.  */
   rarely_quit (++rbc_quitcounter);



reply via email to

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