Subject: bug#78813: feature/igc: [PATCH] Make the array face_attr_sym readonly

From: Helmut Eller <[email-masked]>
Date: Tue, 17 Jun 2025 10:49:10 +0200

Tags: patch

This is a proposal to make the variable face_attr_sym const.  Mostly so
that it's more obvious that it doesn't need to be traced by the GC.

>From 264db35650707c60bbcc5b848a8ac461f56bf6b5 Mon Sep 17 00:00:00 2001
From: Helmut Eller <[email-masked]>
Date: Tue, 17 Jun 2025 09:38:05 +0200
Subject: [PATCH] Make the array face_attr_sym readonly

* src/xfaces.c (face_attr_sym): Make const and initialize.
(init_xfaces): Move initialization to declaration.
---
 src/xfaces.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/xfaces.c b/src/xfaces.c
index 2ca68193876..ea8e97834dc 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1813,7 +1813,27 @@ #define LFACEP(LFACE)					\

 /* Face attribute symbols for each value of LFACE_*_INDEX.  */
-static Lisp_Object face_attr_sym[LFACE_VECTOR_SIZE];
+static const Lisp_Object face_attr_sym[LFACE_VECTOR_SIZE] = {
+  [0] = LISPSYM_INITIALLY (Qface),
+  [LFACE_FOUNDRY_INDEX] = LISPSYM_INITIALLY (QCfoundry),
+  [LFACE_SWIDTH_INDEX] = LISPSYM_INITIALLY (QCwidth),
+  [LFACE_HEIGHT_INDEX] = LISPSYM_INITIALLY (QCheight),
+  [LFACE_WEIGHT_INDEX] = LISPSYM_INITIALLY (QCweight),
+  [LFACE_SLANT_INDEX] = LISPSYM_INITIALLY (QCslant),
+  [LFACE_UNDERLINE_INDEX] = LISPSYM_INITIALLY (QCunderline),
+  [LFACE_INVERSE_INDEX] = LISPSYM_INITIALLY (QCinverse_video),
+  [LFACE_FOREGROUND_INDEX] = LISPSYM_INITIALLY (QCforeground),
+  [LFACE_BACKGROUND_INDEX] = LISPSYM_INITIALLY (QCbackground),
+  [LFACE_STIPPLE_INDEX] = LISPSYM_INITIALLY (QCstipple),
+  [LFACE_OVERLINE_INDEX] = LISPSYM_INITIALLY (QCoverline),
+  [LFACE_STRIKE_THROUGH_INDEX] = LISPSYM_INITIALLY (QCstrike_through),
+  [LFACE_BOX_INDEX] = LISPSYM_INITIALLY (QCbox),
+  [LFACE_FONT_INDEX] = LISPSYM_INITIALLY (QCfont),
+  [LFACE_INHERIT_INDEX] = LISPSYM_INITIALLY (QCinherit),
+  [LFACE_FONTSET_INDEX] = LISPSYM_INITIALLY (QCfontset),
+  [LFACE_DISTANT_FOREGROUND_INDEX] = LISPSYM_INITIALLY (QCdistant_foreground),
+  [LFACE_EXTEND_INDEX] = LISPSYM_INITIALLY (QCextend),
+};
 
 #ifdef GLYPH_DEBUG
 
@@ -7382,26 +7402,6 @@ init_xfaces (void)
 	}
     }
 #endif
-
-  face_attr_sym[0] = Qface;
-  face_attr_sym[LFACE_FOUNDRY_INDEX] = QCfoundry;
-  face_attr_sym[LFACE_SWIDTH_INDEX] = QCwidth;
-  face_attr_sym[LFACE_HEIGHT_INDEX] = QCheight;
-  face_attr_sym[LFACE_WEIGHT_INDEX] = QCweight;
-  face_attr_sym[LFACE_SLANT_INDEX] = QCslant;
-  face_attr_sym[LFACE_UNDERLINE_INDEX] = QCunderline;
-  face_attr_sym[LFACE_INVERSE_INDEX] = QCinverse_video;
-  face_attr_sym[LFACE_FOREGROUND_INDEX] = QCforeground;
-  face_attr_sym[LFACE_BACKGROUND_INDEX] = QCbackground;
-  face_attr_sym[LFACE_STIPPLE_INDEX] = QCstipple;
-  face_attr_sym[LFACE_OVERLINE_INDEX] = QCoverline;
-  face_attr_sym[LFACE_STRIKE_THROUGH_INDEX] = QCstrike_through;
-  face_attr_sym[LFACE_BOX_INDEX] = QCbox;
-  face_attr_sym[LFACE_FONT_INDEX] = QCfont;
-  face_attr_sym[LFACE_INHERIT_INDEX] = QCinherit;
-  face_attr_sym[LFACE_FONTSET_INDEX] = QCfontset;
-  face_attr_sym[LFACE_DISTANT_FOREGROUND_INDEX] = QCdistant_foreground;
-  face_attr_sym[LFACE_EXTEND_INDEX] = QCextend;
 }
 
 void
-- 
2.39.5