summaryrefslogtreecommitdiff
path: root/src/fns.c
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2022-01-26 11:28:33 +0100
committerMattias EngdegÄrd <mattiase@acm.org>2022-01-26 17:10:16 +0100
commita3aeee88aaf843de49e4815e4b2d61743e423441 (patch)
tree8d8ffe2b8584608f76d2a075652f3c38217a8bb0 /src/fns.c
parent826959ccb4ce36c15e2dc3e1fa4a4dbc345875dc (diff)
downloademacs-a3aeee88aaf843de49e4815e4b2d61743e423441.tar.gz
emacs-a3aeee88aaf843de49e4815e4b2d61743e423441.tar.bz2
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/fns.c')
-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)
if (STRINGP (arg))
{
- ptrdiff_t arg_len_byte;
+ ptrdiff_t arg_len_byte = SBYTES (arg);
len = SCHARS (arg);
- arg_len_byte = SBYTES (arg);
if (STRING_MULTIBYTE (arg))
dest_multibyte = true;
else
@@ -986,15 +985,16 @@ concat (ptrdiff_t nargs, Lisp_Object *args, Lisp_Object last_tail,
memory_full (SIZE_MAX);
}
+ /* When the target is a list, return the tail directly if all other
+ arguments are empty. */
+ if (!vector_target && result_len == 0)
+ return last_tail;
+
/* Create the output object. */
Lisp_Object result = vector_target
? make_nil_vector (result_len)
: Fmake_list (make_fixnum (result_len), Qnil);
- /* In `append', if all but last arg are nil, return last arg. */
- if (!vector_target && NILP (result))
- return last_tail;
-
/* Copy the contents of the args into the result. */
Lisp_Object tail = Qnil;
ptrdiff_t toindex = 0;
@@ -1022,14 +1022,12 @@ concat (ptrdiff_t nargs, Lisp_Object *args, Lisp_Object last_tail,
/* Fetch next element of `arg' arg into `elt', or break if
`arg' is exhausted. */
Lisp_Object elt;
- if (NILP (arg))
- break;
if (CONSP (arg))
{
elt = XCAR (arg);
arg = XCDR (arg);
}
- else if (argindex >= arglen)
+ else if (NILP (arg) || argindex >= arglen)
break;
else if (STRINGP (arg))
{