unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Findirect_function
@ 2022-01-14 10:40 Manuel Giraud
  2022-01-14 12:09 ` Mattias Engdegård
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Manuel Giraud @ 2022-01-14 10:40 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 216 bytes --]

Hi,

Maybe it is bike shedding territory (and maybe I'm missing something)
but here are two patches for Findirect_function and its usage. "make
check" is the same and so far it works for me™.

Best regards,

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-simplify-return-case-for-Findirect_function.patch --]
[-- Type: text/x-patch, Size: 805 bytes --]

From 300db08a4d66814000e2d6eb373f931c37913954 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Fri, 14 Jan 2022 11:28:28 +0100
Subject: [PATCH 1/2] simplify return case for Findirect_function.

---
 src/data.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/data.c b/src/data.c
index f287c38fcd..65babc49e9 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2380,10 +2380,8 @@ DEFUN ("indirect-function", Findirect_function, Sindirect_function, 1, 2, 0,
   if (SYMBOLP (result) && !NILP (result)
       && (result = XSYMBOL (result)->u.s.function, SYMBOLP (result)))
     result = indirect_function (result);
-  if (!NILP (result))
-    return result;
 
-  return Qnil;
+  return result;
 }
 \f
 /* Extract and set vector and string elements.  */
-- 
2.34.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-use-Findirect_function-more.patch --]
[-- Type: text/x-patch, Size: 1939 bytes --]

From 99658ecb6860185e0b3fdb8932de3a8b6f7e0f69 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Fri, 14 Jan 2022 11:29:10 +0100
Subject: [PATCH 2/2] use Findirect_function more.

---
 src/eval.c | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/src/eval.c b/src/eval.c
index 5514583b6a..f72eb6f67a 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2668,14 +2668,10 @@ DEFUN ("apply", Fapply, Sapply, 1, MANY, 0,
   numargs += nargs - 2;
 
   /* Optimize for no indirection.  */
-  if (SYMBOLP (fun) && !NILP (fun)
-      && (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun)))
-    {
-      fun = indirect_function (fun);
-      if (NILP (fun))
-	/* Let funcall get the error.  */
-	fun = args[0];
-    }
+  fun = Findirect_function(fun, Qt);
+  if (NILP (fun))
+    /* Let funcall get the error.  */
+    fun = args[0];
 
   if (SUBRP (fun) && XSUBR (fun)->max_args > numargs
       /* Don't hide an error by adding missing arguments.  */
@@ -3069,10 +3065,7 @@ DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0,
  retry:
 
   /* Optimize for no indirection.  */
-  fun = original_fun;
-  if (SYMBOLP (fun) && !NILP (fun)
-      && (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun)))
-    fun = indirect_function (fun);
+  fun = Findirect_function(original_fun, Qt);
 
   if (SUBRP (fun) && !SUBR_NATIVE_COMPILED_DYNP (fun))
     val = funcall_subr (XSUBR (fun), numargs, args + 1);
@@ -3388,13 +3381,7 @@ DEFUN ("func-arity", Ffunc_arity, Sfunc_arity, 1, 1, 0,
  retry:
 
   /* Optimize for no indirection.  */
-  function = original;
-  if (SYMBOLP (function) && !NILP (function))
-    {
-      function = XSYMBOL (function)->u.s.function;
-      if (SYMBOLP (function))
-	function = indirect_function (function);
-    }
+  function = Findirect_function(original, Qt);
 
   if (CONSP (function) && EQ (XCAR (function), Qmacro))
     function = XCDR (function);
-- 
2.34.1


[-- Attachment #4: Type: text/plain, Size: 18 bytes --]

-- 
Manuel Giraud

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-01-18  0:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14 10:40 [PATCH] Findirect_function Manuel Giraud
2022-01-14 12:09 ` Mattias Engdegård
2022-01-14 13:00   ` Manuel Giraud
2022-01-14 12:16 ` Eli Zaretskii
2022-01-14 12:29 ` Andreas Schwab
2022-01-14 13:03   ` Manuel Giraud
2022-01-14 16:27 ` Stefan Monnier
2022-01-14 16:48   ` Manuel Giraud
2022-01-14 17:39     ` Stefan Monnier
2022-01-17 13:32       ` Manuel Giraud
2022-01-17 18:14         ` Stefan Monnier
2022-01-17 18:16         ` Stefan Monnier
2022-01-18  0:43           ` Po Lu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).