aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGemini Lasswell2019-08-03 21:39:29 -0700
committerGemini Lasswell2019-09-13 13:43:07 -0700
commit0dba340da54f129750096a5a8704805a94f5535c (patch)
tree95751e2ab566b4c861241e3edacfcfbccd6e3ea8 /src
parent3bd6ef40b55e429a321c87a09fd94e6ca0e50ae7 (diff)
downloademacs-0dba340da54f129750096a5a8704805a94f5535c.tar.gz
emacs-0dba340da54f129750096a5a8704805a94f5535c.zip
Don't build print-number-table unless it will be used
There are only a few users of print-number-table, and none of them use it when print-circle is nil. A couple of them used to. print_object was changed in 2012-04-20 "* src/print.c (print_preprocess): Only check print_depth if print-circle is nil". byte-compile-output-docform which uses print-number-table binds print-circle to t before printing unless byte-compile-disable-print-circle is set, but that variable has been marked obsolete since 24.1. * src/print.c (print_preprocess): Assert Vprint_circle is non-nil. Remove code handling the case when Vprint_circle is nil. (print, Fprint_preprocess): Don't call print_preprocess unless Vprint_circle is non-nil. (print_object): Remove comment referencing removed code in print_preprocess.
Diffstat (limited to 'src')
-rw-r--r--src/print.c92
1 files changed, 39 insertions, 53 deletions
diff --git a/src/print.c b/src/print.c
index 18330b0fbf4..c870aa5a088 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1120,8 +1120,8 @@ print (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1120 Vprint_number_table = Qnil; 1120 Vprint_number_table = Qnil;
1121 } 1121 }
1122 1122
1123 /* Construct Vprint_number_table for print-gensym and print-circle. */ 1123 /* Construct Vprint_number_table for print-circle. */
1124 if (!NILP (Vprint_gensym) || !NILP (Vprint_circle)) 1124 if (!NILP (Vprint_circle))
1125 { 1125 {
1126 /* Construct Vprint_number_table. 1126 /* Construct Vprint_number_table.
1127 This increments print_number_index for the objects added. */ 1127 This increments print_number_index for the objects added. */
@@ -1163,13 +1163,14 @@ print (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1163 && SYMBOLP (obj) \ 1163 && SYMBOLP (obj) \
1164 && !SYMBOL_INTERNED_P (obj))) 1164 && !SYMBOL_INTERNED_P (obj)))
1165 1165
1166/* Construct Vprint_number_table according to the structure of OBJ. 1166/* Construct Vprint_number_table for the print-circle feature
1167 OBJ itself and all its elements will be added to Vprint_number_table 1167 according to the structure of OBJ. OBJ itself and all its elements
1168 recursively if it is a list, vector, compiled function, char-table, 1168 will be added to Vprint_number_table recursively if it is a list,
1169 string (its text properties will be traced), or a symbol that has 1169 vector, compiled function, char-table, string (its text properties
1170 no obarray (this is for the print-gensym feature). 1170 will be traced), or a symbol that has no obarray (this is for the
1171 The status fields of Vprint_number_table mean whether each object appears 1171 print-gensym feature). The status fields of Vprint_number_table
1172 more than once in OBJ: Qnil at the first time, and Qt after that. */ 1172 mean whether each object appears more than once in OBJ: Qnil at the
1173 first time, and Qt after that. */
1173static void 1174static void
1174print_preprocess (Lisp_Object obj) 1175print_preprocess (Lisp_Object obj)
1175{ 1176{
@@ -1178,20 +1179,7 @@ print_preprocess (Lisp_Object obj)
1178 int loop_count = 0; 1179 int loop_count = 0;
1179 Lisp_Object halftail; 1180 Lisp_Object halftail;
1180 1181
1181 /* Avoid infinite recursion for circular nested structure 1182 eassert (!NILP (Vprint_circle));
1182 in the case where Vprint_circle is nil. */
1183 if (NILP (Vprint_circle))
1184 {
1185 /* Give up if we go so deep that print_object will get an error. */
1186 /* See similar code in print_object. */
1187 if (print_depth >= PRINT_CIRCLE)
1188 error ("Apparently circular structure being printed");
1189
1190 for (i = 0; i < print_depth; i++)
1191 if (EQ (obj, being_printed[i]))
1192 return;
1193 being_printed[print_depth] = obj;
1194 }
1195 1183
1196 print_depth++; 1184 print_depth++;
1197 halftail = obj; 1185 halftail = obj;
@@ -1202,33 +1190,28 @@ print_preprocess (Lisp_Object obj)
1202 if (!HASH_TABLE_P (Vprint_number_table)) 1190 if (!HASH_TABLE_P (Vprint_number_table))
1203 Vprint_number_table = CALLN (Fmake_hash_table, QCtest, Qeq); 1191 Vprint_number_table = CALLN (Fmake_hash_table, QCtest, Qeq);
1204 1192
1205 /* In case print-circle is nil and print-gensym is t, 1193 Lisp_Object num = Fgethash (obj, Vprint_number_table, Qnil);
1206 add OBJ to Vprint_number_table only when OBJ is a symbol. */ 1194 if (!NILP (num)
1207 if (! NILP (Vprint_circle) || SYMBOLP (obj)) 1195 /* If Vprint_continuous_numbering is non-nil and OBJ is a gensym,
1208 { 1196 always print the gensym with a number. This is a special for
1209 Lisp_Object num = Fgethash (obj, Vprint_number_table, Qnil); 1197 the lisp function byte-compile-output-docform. */
1210 if (!NILP (num) 1198 || (!NILP (Vprint_continuous_numbering)
1211 /* If Vprint_continuous_numbering is non-nil and OBJ is a gensym, 1199 && SYMBOLP (obj)
1212 always print the gensym with a number. This is a special for 1200 && !SYMBOL_INTERNED_P (obj)))
1213 the lisp function byte-compile-output-docform. */ 1201 { /* OBJ appears more than once. Let's remember that. */
1214 || (!NILP (Vprint_continuous_numbering) 1202 if (!FIXNUMP (num))
1215 && SYMBOLP (obj) 1203 {
1216 && !SYMBOL_INTERNED_P (obj))) 1204 print_number_index++;
1217 { /* OBJ appears more than once. Let's remember that. */ 1205 /* Negative number indicates it hasn't been printed yet. */
1218 if (!FIXNUMP (num)) 1206 Fputhash (obj, make_fixnum (- print_number_index),
1219 { 1207 Vprint_number_table);
1220 print_number_index++;
1221 /* Negative number indicates it hasn't been printed yet. */
1222 Fputhash (obj, make_fixnum (- print_number_index),
1223 Vprint_number_table);
1224 }
1225 print_depth--;
1226 return;
1227 } 1208 }
1228 else 1209 print_depth--;
1229 /* OBJ is not yet recorded. Let's add to the table. */ 1210 return;
1230 Fputhash (obj, Qt, Vprint_number_table);
1231 } 1211 }
1212 else
1213 /* OBJ is not yet recorded. Let's add to the table. */
1214 Fputhash (obj, Qt, Vprint_number_table);
1232 1215
1233 switch (XTYPE (obj)) 1216 switch (XTYPE (obj))
1234 { 1217 {
@@ -1275,11 +1258,15 @@ print_preprocess (Lisp_Object obj)
1275 1258
1276DEFUN ("print--preprocess", Fprint_preprocess, Sprint_preprocess, 1, 1, 0, 1259DEFUN ("print--preprocess", Fprint_preprocess, Sprint_preprocess, 1, 1, 0,
1277 doc: /* Extract sharing info from OBJECT needed to print it. 1260 doc: /* Extract sharing info from OBJECT needed to print it.
1278Fills `print-number-table'. */) 1261Fills `print-number-table' if `print-circle' is non-nil. Does nothing
1279 (Lisp_Object object) 1262if `print-circle' is nil. */)
1263 (Lisp_Object object)
1280{ 1264{
1281 print_number_index = 0; 1265 if (!NILP (Vprint_circle))
1282 print_preprocess (object); 1266 {
1267 print_number_index = 0;
1268 print_preprocess (object);
1269 }
1283 return Qnil; 1270 return Qnil;
1284} 1271}
1285 1272
@@ -1864,7 +1851,6 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1864 /* Simple but incomplete way. */ 1851 /* Simple but incomplete way. */
1865 int i; 1852 int i;
1866 1853
1867 /* See similar code in print_preprocess. */
1868 if (print_depth >= PRINT_CIRCLE) 1854 if (print_depth >= PRINT_CIRCLE)
1869 error ("Apparently circular structure being printed"); 1855 error ("Apparently circular structure being printed");
1870 1856