aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorPaul Eggert2019-03-04 00:00:39 -0800
committerPaul Eggert2019-03-04 00:05:04 -0800
commit5c2563a5472cd5580e7af570aa320ac581ad1985 (patch)
treefbf88ede49dc0ba527d3925dfc274c230b8cf95f /src/coding.c
parentd6b3e5bbc5e14c32f3faad9f1481ec16807ac2fe (diff)
downloademacs-5c2563a5472cd5580e7af570aa320ac581ad1985.tar.gz
emacs-5c2563a5472cd5580e7af570aa320ac581ad1985.zip
Simplify list creation in C code
The main new thing here is that C code can now say ‘list (a, b, c, d, e, f)’ instead of ‘listn (CONSTYPE_HEAP, 6, a, b, c, d, e, f)’, thus relieving callers of the responsibility of counting arguments (plus, the code feels more like Lisp). The old list1 ... list5 functions remain, as they’re probably a bit faster for small lists. * src/alloc.c (cons_listn, pure_listn): New functions. (listn): Omit enum argument. All callers changed to use either new ‘list’ or ‘pure_list’ macros. * src/charset.c (Fdefine_charset_internal): * src/coding.c (detect_coding_system) (Fset_terminal_coding_system_internal): * src/frame.c (frame_size_history_add, adjust_frame_size): * src/gtkutil.c (xg_frame_set_char_size): * src/keyboard.c (command_loop_1): * src/nsfns.m (frame_geometry): * src/widget.c (set_frame_size): * src/xfaces.c (Fcolor_distance): * src/xfns.c (frame_geometry): * src/xterm.c (x_set_window_size_1): * src/xwidget.c (Fxwidget_size_request): Prefer list1i, list2i, etc. to open-coding them. * src/charset.c (Fset_charset_priority): * src/nsterm.m (append2): * src/window.c (window_list): * src/xfaces.c (Fx_list_fonts): Use nconc2 instead of open-coding it. * src/eval.c (eval_sub, backtrace_frame_apply): * src/kqueue.c (kqueue_generate_event): * src/nsterm.m (performDragOperation:): * src/pdumper.c (Fpdumper_stats): * src/w32.c (init_environment): Prefer list1, list2, etc. to open-coding them. * src/font.c (font_list_entities): Parenthesize to avoid expanding new ‘list’ macro. * src/gtkutil.c (GETSETUP): Rename from MAKE_FLOAT_PAGE_SETUP to get lines to fit. Move outside the ‘list’ call, since it’s now a macro. * src/keymap.c (Fmake_keymap): Simplify. * src/lisp.h (list, pure_list): New macros. (list1i): New function.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/coding.c b/src/coding.c
index e470757f92e..a216460fc2c 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -8720,20 +8720,20 @@ detect_coding_system (const unsigned char *src,
8720 { 8720 {
8721 detect_info.found = CATEGORY_MASK_RAW_TEXT; 8721 detect_info.found = CATEGORY_MASK_RAW_TEXT;
8722 id = CODING_SYSTEM_ID (Qno_conversion); 8722 id = CODING_SYSTEM_ID (Qno_conversion);
8723 val = list1 (make_fixnum (id)); 8723 val = list1i (id);
8724 } 8724 }
8725 else if (! detect_info.rejected && ! detect_info.found) 8725 else if (! detect_info.rejected && ! detect_info.found)
8726 { 8726 {
8727 detect_info.found = CATEGORY_MASK_ANY; 8727 detect_info.found = CATEGORY_MASK_ANY;
8728 id = coding_categories[coding_category_undecided].id; 8728 id = coding_categories[coding_category_undecided].id;
8729 val = list1 (make_fixnum (id)); 8729 val = list1i (id);
8730 } 8730 }
8731 else if (highest) 8731 else if (highest)
8732 { 8732 {
8733 if (detect_info.found) 8733 if (detect_info.found)
8734 { 8734 {
8735 detect_info.found = 1 << category; 8735 detect_info.found = 1 << category;
8736 val = list1 (make_fixnum (this->id)); 8736 val = list1i (this->id);
8737 } 8737 }
8738 else 8738 else
8739 for (i = 0; i < coding_category_raw_text; i++) 8739 for (i = 0; i < coding_category_raw_text; i++)
@@ -8741,7 +8741,7 @@ detect_coding_system (const unsigned char *src,
8741 { 8741 {
8742 detect_info.found = 1 << coding_priorities[i]; 8742 detect_info.found = 1 << coding_priorities[i];
8743 id = coding_categories[coding_priorities[i]].id; 8743 id = coding_categories[coding_priorities[i]].id;
8744 val = list1 (make_fixnum (id)); 8744 val = list1i (id);
8745 break; 8745 break;
8746 } 8746 }
8747 } 8747 }
@@ -8758,7 +8758,7 @@ detect_coding_system (const unsigned char *src,
8758 found |= 1 << category; 8758 found |= 1 << category;
8759 id = coding_categories[category].id; 8759 id = coding_categories[category].id;
8760 if (id >= 0) 8760 if (id >= 0)
8761 val = list1 (make_fixnum (id)); 8761 val = list1i (id);
8762 } 8762 }
8763 } 8763 }
8764 for (i = coding_category_raw_text - 1; i >= 0; i--) 8764 for (i = coding_category_raw_text - 1; i >= 0; i--)
@@ -8783,7 +8783,7 @@ detect_coding_system (const unsigned char *src,
8783 this = coding_categories + coding_category_utf_8_sig; 8783 this = coding_categories + coding_category_utf_8_sig;
8784 else 8784 else
8785 this = coding_categories + coding_category_utf_8_nosig; 8785 this = coding_categories + coding_category_utf_8_nosig;
8786 val = list1 (make_fixnum (this->id)); 8786 val = list1i (this->id);
8787 } 8787 }
8788 } 8788 }
8789 else if (base_category == coding_category_utf_16_auto) 8789 else if (base_category == coding_category_utf_16_auto)
@@ -8800,13 +8800,13 @@ detect_coding_system (const unsigned char *src,
8800 this = coding_categories + coding_category_utf_16_be_nosig; 8800 this = coding_categories + coding_category_utf_16_be_nosig;
8801 else 8801 else
8802 this = coding_categories + coding_category_utf_16_le_nosig; 8802 this = coding_categories + coding_category_utf_16_le_nosig;
8803 val = list1 (make_fixnum (this->id)); 8803 val = list1i (this->id);
8804 } 8804 }
8805 } 8805 }
8806 else 8806 else
8807 { 8807 {
8808 detect_info.found = 1 << XFIXNUM (CODING_ATTR_CATEGORY (attrs)); 8808 detect_info.found = 1 << XFIXNUM (CODING_ATTR_CATEGORY (attrs));
8809 val = list1 (make_fixnum (coding.id)); 8809 val = list1i (coding.id);
8810 } 8810 }
8811 8811
8812 /* Then, detect eol-format if necessary. */ 8812 /* Then, detect eol-format if necessary. */
@@ -9749,7 +9749,7 @@ DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_intern
9749 tset_charset_list 9749 tset_charset_list
9750 (term, (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK 9750 (term, (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK
9751 ? coding_charset_list (terminal_coding) 9751 ? coding_charset_list (terminal_coding)
9752 : list1 (make_fixnum (charset_ascii)))); 9752 : list1i (charset_ascii)));
9753 return Qnil; 9753 return Qnil;
9754} 9754}
9755 9755
@@ -10856,7 +10856,7 @@ syms_of_coding (void)
10856 /* Error signaled when there's a problem with detecting a coding system. */ 10856 /* Error signaled when there's a problem with detecting a coding system. */
10857 DEFSYM (Qcoding_system_error, "coding-system-error"); 10857 DEFSYM (Qcoding_system_error, "coding-system-error");
10858 Fput (Qcoding_system_error, Qerror_conditions, 10858 Fput (Qcoding_system_error, Qerror_conditions,
10859 listn (CONSTYPE_PURE, 2, Qcoding_system_error, Qerror)); 10859 pure_list (Qcoding_system_error, Qerror));
10860 Fput (Qcoding_system_error, Qerror_message, 10860 Fput (Qcoding_system_error, Qerror_message,
10861 build_pure_c_string ("Invalid coding system")); 10861 build_pure_c_string ("Invalid coding system"));
10862 10862
@@ -11298,7 +11298,7 @@ internal character representation. */);
11298 /* This is already set. 11298 /* This is already set.
11299 plist[7] = args[coding_arg_ascii_compatible_p] = Qt; */ 11299 plist[7] = args[coding_arg_ascii_compatible_p] = Qt; */
11300 plist[8] = intern_c_string (":charset-list"); 11300 plist[8] = intern_c_string (":charset-list");
11301 plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil); 11301 plist[9] = args[coding_arg_charset_list] = list1 (Qascii);
11302 plist[11] = args[coding_arg_for_unibyte] = Qnil; 11302 plist[11] = args[coding_arg_for_unibyte] = Qnil;
11303 plist[13] = build_pure_c_string ("No conversion on encoding, " 11303 plist[13] = build_pure_c_string ("No conversion on encoding, "
11304 "automatic conversion on decoding."); 11304 "automatic conversion on decoding.");