]> git.eshelyaron.com Git - emacs.git/commitdiff
Realloc less often in adjust_glyph_matrix (bug#77961)
authorGerd Möllmann <gerd.moellmann@gmail.com>
Tue, 22 Apr 2025 09:35:12 +0000 (11:35 +0200)
committerEshel Yaron <me@eshelyaron.com>
Tue, 22 Apr 2025 17:57:24 +0000 (19:57 +0200)
* src/dispnew.c (adjust_glyph_matrix): Only xnrealloc when the
glyph matrix got wider or taller.

(cherry picked from commit 871ec9615a949e967bf7d19466eb9c56ed80ff7e)

src/dispnew.c

index ff14efe0c4aefa6fd4ac38e2850b5c101f9415d8..9257bb717745dd40d2aa267f861cb99bdc2e42d6 100644 (file)
@@ -503,13 +503,17 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
 
          while (row < end)
            {
-             row->glyphs[LEFT_MARGIN_AREA]
-               = xnrealloc (row->glyphs[LEFT_MARGIN_AREA],
-                            dim.width, sizeof (struct glyph));
-             /* We actually need to clear only the 'frame' member, but
-                 it's easier to clear everything.  */
-             memset (row->glyphs[LEFT_MARGIN_AREA], 0,
-                     dim.width * sizeof (struct glyph));
+             /* Only realloc if matrix got wider or taller (bug#77961).  */
+             if (dim.width > matrix->matrix_w || new_rows)
+               {
+                 row->glyphs[LEFT_MARGIN_AREA]
+                   = xnrealloc (row->glyphs[LEFT_MARGIN_AREA],
+                                dim.width, sizeof (struct glyph));
+                 /* We actually need to clear only the 'frame' member, but
+                    it's easier to clear everything.  */
+                 memset (row->glyphs[LEFT_MARGIN_AREA], 0,
+                         dim.width * sizeof (struct glyph));
+               }
 
              if ((row == matrix->rows + dim.height - 1
                   /* The mode line, if displayed, never has marginal