aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorPaul Eggert2013-07-15 23:39:49 -0700
committerPaul Eggert2013-07-15 23:39:49 -0700
commit6c6f1994bf684f510d600bd18023fa01b4b06500 (patch)
tree04b7125d1327d8419024f28d14bfb384afc52cdd /src/coding.c
parent8abee653a22b0b879a9376c1dce3e3ca2e2f31d6 (diff)
downloademacs-6c6f1994bf684f510d600bd18023fa01b4b06500.tar.gz
emacs-6c6f1994bf684f510d600bd18023fa01b4b06500.zip
Prefer list1 (X) to Fcons (X, Qnil) when building lists.
This makes the code easier to read and the executable a bit smaller. Do not replace all calls to Fcons that happen to create lists, just calls that are intended to create lists. For example, when creating an alist that maps FOO to nil, use list1 (Fcons (FOO, Qnil)) rather than list1 (list1 (FOO)) or Fcons (Fcons (FOO, Qnil), Qnil). Similarly for list2 through list5. * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): * bytecode.c (exec_byte_code): * callint.c (quotify_arg, Fcall_interactively): * callproc.c (Fcall_process, create_temp_file): * charset.c (load_charset_map_from_file) (Fdefine_charset_internal, init_charset): * coding.c (get_translation_table, detect_coding_system) (Fcheck_coding_systems_region) (Fset_terminal_coding_system_internal) (Fdefine_coding_system_internal, Fdefine_coding_system_alias): * composite.c (update_compositions, Ffind_composition_internal): * dired.c (directory_files_internal, file_name_completion) (Fsystem_users): * dispnew.c (Fopen_termscript, bitch_at_user, init_display): * doc.c (Fsnarf_documentation): * editfns.c (Fmessage_box): * emacs.c (main): * eval.c (do_debug_on_call, signal_error, maybe_call_debugger) (Feval, eval_sub, Ffuncall, apply_lambda): * fileio.c (make_temp_name, Fcopy_file, Faccess_file) (Fset_file_selinux_context, Fset_file_acl, Fset_file_modes) (Fset_file_times, Finsert_file_contents) (Fchoose_write_coding_system, Fwrite_region): * fns.c (Flax_plist_put, Fyes_or_no_p, syms_of_fns): * font.c (font_registry_charsets, font_parse_fcname) (font_prepare_cache, font_update_drivers, Flist_fonts): * fontset.c (Fset_fontset_font, Ffontset_info, syms_of_fontset): * frame.c (make_frame, Fmake_terminal_frame) (x_set_frame_parameters, x_report_frame_params) (x_default_parameter, Fx_parse_geometry): * ftfont.c (syms_of_ftfont): * image.c (gif_load): * keyboard.c (command_loop_1): * keymap.c (Fmake_keymap, Fmake_sparse_keymap, access_keymap_1) (Fcopy_keymap, append_key, Fcurrent_active_maps) (Fminor_mode_key_binding, accessible_keymaps_1) (Faccessible_keymaps, Fwhere_is_internal): * lread.c (read_emacs_mule_char): * menu.c (find_and_return_menu_selection): * minibuf.c (get_minibuffer): * nsfns.m (Fns_perform_service): * nsfont.m (ns_script_to_charset): * nsmenu.m (ns_popup_dialog): * nsselect.m (ns_get_local_selection, ns_string_from_pasteboard) (Fx_own_selection_internal): * nsterm.m (append2): * print.c (Fredirect_debugging_output) (print_prune_string_charset): * process.c (Fdelete_process, Fprocess_contact) (Fformat_network_address, set_socket_option) (read_and_dispose_of_process_output, write_queue_push) (send_process, exec_sentinel): * sound.c (Fplay_sound_internal): * textprop.c (validate_plist, add_properties) (Fput_text_property, Fadd_face_text_property) (copy_text_properties, text_property_list, syms_of_textprop): * unexaix.c (report_error): * unexcoff.c (report_error): * unexsol.c (unexec): * xdisp.c (redisplay_tool_bar, store_mode_line_string) (Fformat_mode_line, syms_of_xdisp): * xfaces.c (set_font_frame_param) (Finternal_lisp_face_attribute_values) (Finternal_merge_in_global_face, syms_of_xfaces): * xfns.c (x_default_scroll_bar_color_parameter) (x_default_font_parameter, x_create_tip_frame): * xfont.c (xfont_supported_scripts): * xmenu.c (Fx_popup_dialog, xmenu_show, xdialog_show) (menu_help_callback, xmenu_show): * xml.c (make_dom): * xterm.c (set_wm_state): Prefer list1 (FOO) to Fcons (FOO, Qnil) when creating a list, and similarly for list2 through list5.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/coding.c b/src/coding.c
index a1494ad38aa..8dcc4013c1d 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -6864,11 +6864,9 @@ get_translation_table (Lisp_Object attrs, bool encodep, int *max_lookup)
6864 if (CHAR_TABLE_P (standard)) 6864 if (CHAR_TABLE_P (standard))
6865 { 6865 {
6866 if (CONSP (translation_table)) 6866 if (CONSP (translation_table))
6867 translation_table = nconc2 (translation_table, 6867 translation_table = nconc2 (translation_table, list1 (standard));
6868 Fcons (standard, Qnil));
6869 else 6868 else
6870 translation_table = Fcons (translation_table, 6869 translation_table = list2 (translation_table, standard);
6871 Fcons (standard, Qnil));
6872 } 6870 }
6873 } 6871 }
6874 6872
@@ -8667,20 +8665,20 @@ detect_coding_system (const unsigned char *src,
8667 { 8665 {
8668 detect_info.found = CATEGORY_MASK_RAW_TEXT; 8666 detect_info.found = CATEGORY_MASK_RAW_TEXT;
8669 id = CODING_SYSTEM_ID (Qno_conversion); 8667 id = CODING_SYSTEM_ID (Qno_conversion);
8670 val = Fcons (make_number (id), Qnil); 8668 val = list1 (make_number (id));
8671 } 8669 }
8672 else if (! detect_info.rejected && ! detect_info.found) 8670 else if (! detect_info.rejected && ! detect_info.found)
8673 { 8671 {
8674 detect_info.found = CATEGORY_MASK_ANY; 8672 detect_info.found = CATEGORY_MASK_ANY;
8675 id = coding_categories[coding_category_undecided].id; 8673 id = coding_categories[coding_category_undecided].id;
8676 val = Fcons (make_number (id), Qnil); 8674 val = list1 (make_number (id));
8677 } 8675 }
8678 else if (highest) 8676 else if (highest)
8679 { 8677 {
8680 if (detect_info.found) 8678 if (detect_info.found)
8681 { 8679 {
8682 detect_info.found = 1 << category; 8680 detect_info.found = 1 << category;
8683 val = Fcons (make_number (this->id), Qnil); 8681 val = list1 (make_number (this->id));
8684 } 8682 }
8685 else 8683 else
8686 for (i = 0; i < coding_category_raw_text; i++) 8684 for (i = 0; i < coding_category_raw_text; i++)
@@ -8688,7 +8686,7 @@ detect_coding_system (const unsigned char *src,
8688 { 8686 {
8689 detect_info.found = 1 << coding_priorities[i]; 8687 detect_info.found = 1 << coding_priorities[i];
8690 id = coding_categories[coding_priorities[i]].id; 8688 id = coding_categories[coding_priorities[i]].id;
8691 val = Fcons (make_number (id), Qnil); 8689 val = list1 (make_number (id));
8692 break; 8690 break;
8693 } 8691 }
8694 } 8692 }
@@ -8705,7 +8703,7 @@ detect_coding_system (const unsigned char *src,
8705 found |= 1 << category; 8703 found |= 1 << category;
8706 id = coding_categories[category].id; 8704 id = coding_categories[category].id;
8707 if (id >= 0) 8705 if (id >= 0)
8708 val = Fcons (make_number (id), val); 8706 val = list1 (make_number (id));
8709 } 8707 }
8710 } 8708 }
8711 for (i = coding_category_raw_text - 1; i >= 0; i--) 8709 for (i = coding_category_raw_text - 1; i >= 0; i--)
@@ -8730,7 +8728,7 @@ detect_coding_system (const unsigned char *src,
8730 this = coding_categories + coding_category_utf_8_sig; 8728 this = coding_categories + coding_category_utf_8_sig;
8731 else 8729 else
8732 this = coding_categories + coding_category_utf_8_nosig; 8730 this = coding_categories + coding_category_utf_8_nosig;
8733 val = Fcons (make_number (this->id), Qnil); 8731 val = list1 (make_number (this->id));
8734 } 8732 }
8735 } 8733 }
8736 else if (base_category == coding_category_utf_16_auto) 8734 else if (base_category == coding_category_utf_16_auto)
@@ -8747,13 +8745,13 @@ detect_coding_system (const unsigned char *src,
8747 this = coding_categories + coding_category_utf_16_be_nosig; 8745 this = coding_categories + coding_category_utf_16_be_nosig;
8748 else 8746 else
8749 this = coding_categories + coding_category_utf_16_le_nosig; 8747 this = coding_categories + coding_category_utf_16_le_nosig;
8750 val = Fcons (make_number (this->id), Qnil); 8748 val = list1 (make_number (this->id));
8751 } 8749 }
8752 } 8750 }
8753 else 8751 else
8754 { 8752 {
8755 detect_info.found = 1 << XINT (CODING_ATTR_CATEGORY (attrs)); 8753 detect_info.found = 1 << XINT (CODING_ATTR_CATEGORY (attrs));
8756 val = Fcons (make_number (coding.id), Qnil); 8754 val = list1 (make_number (coding.id));
8757 } 8755 }
8758 8756
8759 /* Then, detect eol-format if necessary. */ 8757 /* Then, detect eol-format if necessary. */
@@ -9224,7 +9222,7 @@ is nil. */)
9224 attrs = AREF (CODING_SYSTEM_SPEC (elt), 0); 9222 attrs = AREF (CODING_SYSTEM_SPEC (elt), 0);
9225 ASET (attrs, coding_attr_trans_tbl, 9223 ASET (attrs, coding_attr_trans_tbl,
9226 get_translation_table (attrs, 1, NULL)); 9224 get_translation_table (attrs, 1, NULL));
9227 list = Fcons (Fcons (elt, Fcons (attrs, Qnil)), list); 9225 list = Fcons (list2 (elt, attrs), list);
9228 } 9226 }
9229 9227
9230 if (STRINGP (start)) 9228 if (STRINGP (start))
@@ -9635,7 +9633,7 @@ DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_intern
9635 tset_charset_list 9633 tset_charset_list
9636 (term, (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK 9634 (term, (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK
9637 ? coding_charset_list (terminal_coding) 9635 ? coding_charset_list (terminal_coding)
9638 : Fcons (make_number (charset_ascii), Qnil))); 9636 : list1 (make_number (charset_ascii))));
9639 return Qnil; 9637 return Qnil;
9640} 9638}
9641 9639
@@ -10080,9 +10078,9 @@ usage: (define-coding-system-internal ...) */)
10080 { 10078 {
10081 dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (tmp))); 10079 dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (tmp)));
10082 if (dim < dim2) 10080 if (dim < dim2)
10083 tmp = Fcons (XCAR (tail), Fcons (tmp, Qnil)); 10081 tmp = list2 (XCAR (tail), tmp);
10084 else 10082 else
10085 tmp = Fcons (tmp, Fcons (XCAR (tail), Qnil)); 10083 tmp = list2 (tmp, XCAR (tail));
10086 } 10084 }
10087 else 10085 else
10088 { 10086 {
@@ -10093,7 +10091,7 @@ usage: (define-coding-system-internal ...) */)
10093 break; 10091 break;
10094 } 10092 }
10095 if (NILP (tmp2)) 10093 if (NILP (tmp2))
10096 tmp = nconc2 (tmp, Fcons (XCAR (tail), Qnil)); 10094 tmp = nconc2 (tmp, list1 (XCAR (tail)));
10097 else 10095 else
10098 { 10096 {
10099 XSETCDR (tmp2, Fcons (XCAR (tmp2), XCDR (tmp2))); 10097 XSETCDR (tmp2, Fcons (XCAR (tmp2), XCDR (tmp2)));
@@ -10411,7 +10409,7 @@ usage: (define-coding-system-internal ...) */)
10411 && ! EQ (eol_type, Qmac)) 10409 && ! EQ (eol_type, Qmac))
10412 error ("Invalid eol-type"); 10410 error ("Invalid eol-type");
10413 10411
10414 aliases = Fcons (name, Qnil); 10412 aliases = list1 (name);
10415 10413
10416 if (NILP (eol_type)) 10414 if (NILP (eol_type))
10417 { 10415 {
@@ -10421,7 +10419,7 @@ usage: (define-coding-system-internal ...) */)
10421 Lisp_Object this_spec, this_name, this_aliases, this_eol_type; 10419 Lisp_Object this_spec, this_name, this_aliases, this_eol_type;
10422 10420
10423 this_name = AREF (eol_type, i); 10421 this_name = AREF (eol_type, i);
10424 this_aliases = Fcons (this_name, Qnil); 10422 this_aliases = list1 (this_name);
10425 this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac); 10423 this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac);
10426 this_spec = make_uninit_vector (3); 10424 this_spec = make_uninit_vector (3);
10427 ASET (this_spec, 0, attrs); 10425 ASET (this_spec, 0, attrs);
@@ -10536,7 +10534,7 @@ DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias,
10536 list. */ 10534 list. */
10537 while (!NILP (XCDR (aliases))) 10535 while (!NILP (XCDR (aliases)))
10538 aliases = XCDR (aliases); 10536 aliases = XCDR (aliases);
10539 XSETCDR (aliases, Fcons (alias, Qnil)); 10537 XSETCDR (aliases, list1 (alias));
10540 10538
10541 eol_type = AREF (spec, 2); 10539 eol_type = AREF (spec, 2);
10542 if (VECTORP (eol_type)) 10540 if (VECTORP (eol_type))