From: Stefan Monnier Date: Thu, 16 Jun 2022 18:05:26 +0000 (-0400) Subject: * src/fns.c (Fmapconcat): Optimize the case where separator=="" X-Git-Tag: emacs-29.0.90~1447^2~1699 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e75ce9ca384d2f0c52c2a5b53eb9cbac9111956f;p=emacs.git * src/fns.c (Fmapconcat): Optimize the case where separator=="" --- diff --git a/src/fns.c b/src/fns.c index 4df944507c7..a6ceac29355 100644 --- a/src/fns.c +++ b/src/fns.c @@ -2834,12 +2834,18 @@ FUNCTION must be a function of one argument, and must return a value SAFE_ALLOCA_LISP (args, args_alloc); ptrdiff_t nmapped = mapcar1 (leni, args, function, sequence); ptrdiff_t nargs = 2 * nmapped - 1; + eassert (nmapped == leni); - for (ptrdiff_t i = nmapped - 1; i > 0; i--) - args[i + i] = args[i]; + if (!NILP (Fequal (separator, empty_multibyte_string))) + nargs = nmapped; + else + { + for (ptrdiff_t i = nmapped - 1; i > 0; i--) + args[i + i] = args[i]; - for (ptrdiff_t i = 1; i < nargs; i += 2) - args[i] = separator; + for (ptrdiff_t i = 1; i < nargs; i += 2) + args[i] = separator; + } Lisp_Object ret = Fconcat (nargs, args); SAFE_FREE ();