aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias EngdegÄrd2022-01-26 11:28:33 +0100
committerMattias EngdegÄrd2022-01-26 17:10:16 +0100
commita3aeee88aaf843de49e4815e4b2d61743e423441 (patch)
tree8d8ffe2b8584608f76d2a075652f3c38217a8bb0 /src
parent826959ccb4ce36c15e2dc3e1fa4a4dbc345875dc (diff)
downloademacs-a3aeee88aaf843de49e4815e4b2d61743e423441.tar.gz
emacs-a3aeee88aaf843de49e4815e4b2d61743e423441.zip
Minor `concat` tweaks
* src/fns.c (concat): Do things in the right order for speed. (concat_strings): Initialise variable.
Diffstat (limited to 'src')
-rw-r--r--src/fns.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/fns.c b/src/fns.c
index 87237f3b5e4..16f1ebe4392 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -790,9 +790,8 @@ concat_strings (ptrdiff_t nargs, Lisp_Object *args)
790 790
791 if (STRINGP (arg)) 791 if (STRINGP (arg))
792 { 792 {
793 ptrdiff_t arg_len_byte; 793 ptrdiff_t arg_len_byte = SBYTES (arg);
794 len = SCHARS (arg); 794 len = SCHARS (arg);
795 arg_len_byte = SBYTES (arg);
796 if (STRING_MULTIBYTE (arg)) 795 if (STRING_MULTIBYTE (arg))
797 dest_multibyte = true; 796 dest_multibyte = true;
798 else 797 else
@@ -986,15 +985,16 @@ concat (ptrdiff_t nargs, Lisp_Object *args, Lisp_Object last_tail,
986 memory_full (SIZE_MAX); 985 memory_full (SIZE_MAX);
987 } 986 }
988 987
988 /* When the target is a list, return the tail directly if all other
989 arguments are empty. */
990 if (!vector_target && result_len == 0)
991 return last_tail;
992
989 /* Create the output object. */ 993 /* Create the output object. */
990 Lisp_Object result = vector_target 994 Lisp_Object result = vector_target
991 ? make_nil_vector (result_len) 995 ? make_nil_vector (result_len)
992 : Fmake_list (make_fixnum (result_len), Qnil); 996 : Fmake_list (make_fixnum (result_len), Qnil);
993 997
994 /* In `append', if all but last arg are nil, return last arg. */
995 if (!vector_target && NILP (result))
996 return last_tail;
997
998 /* Copy the contents of the args into the result. */ 998 /* Copy the contents of the args into the result. */
999 Lisp_Object tail = Qnil; 999 Lisp_Object tail = Qnil;
1000 ptrdiff_t toindex = 0; 1000 ptrdiff_t toindex = 0;
@@ -1022,14 +1022,12 @@ concat (ptrdiff_t nargs, Lisp_Object *args, Lisp_Object last_tail,
1022 /* Fetch next element of `arg' arg into `elt', or break if 1022 /* Fetch next element of `arg' arg into `elt', or break if
1023 `arg' is exhausted. */ 1023 `arg' is exhausted. */
1024 Lisp_Object elt; 1024 Lisp_Object elt;
1025 if (NILP (arg))
1026 break;
1027 if (CONSP (arg)) 1025 if (CONSP (arg))
1028 { 1026 {
1029 elt = XCAR (arg); 1027 elt = XCAR (arg);
1030 arg = XCDR (arg); 1028 arg = XCDR (arg);
1031 } 1029 }
1032 else if (argindex >= arglen) 1030 else if (NILP (arg) || argindex >= arglen)
1033 break; 1031 break;
1034 else if (STRINGP (arg)) 1032 else if (STRINGP (arg))
1035 { 1033 {