From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud Newsgroups: gmane.emacs.devel Subject: [PATCH] Findirect_function Date: Fri, 14 Jan 2022 11:40:02 +0100 Message-ID: <87tue61tz1.fsf@elite.giraud> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14033"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (berkeley-unix) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 14 11:42:57 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n8K2q-0003TA-Nk for ged-emacs-devel@m.gmane-mx.org; Fri, 14 Jan 2022 11:42:56 +0100 Original-Received: from localhost ([::1]:40022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8K2p-0002aI-OF for ged-emacs-devel@m.gmane-mx.org; Fri, 14 Jan 2022 05:42:55 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8K0F-0007yj-JF for emacs-devel@gnu.org; Fri, 14 Jan 2022 05:40:18 -0500 Original-Received: from ledu-giraud.fr ([51.159.28.247]:20134) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8K0B-0007hx-SN for emacs-devel@gnu.org; Fri, 14 Jan 2022 05:40:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=PFJGsAfvSGgM9TnN 2a8diXeDfRWmp5ASXjzv15XSIgc=; h=date:subject:to:from; d=ledu-giraud.fr; b=l6CwIRtn6MUdJa9L6LaaBuNakjEn1Z3aXq8XPCKqks5LdXqQci ao3bjVRN6T3+UaE31V04TN+ioVks/SWnXMJSQXvmM++NEioIjWE9pA7bKiy4CbNuDTS2ae M1QgWmFfACYBaOjJYF7WsN/WMyyyE0mMu+ULZnfLN/CKK3yxtS+cUmIYLDyeVW6Hpz96Kn L6LUl55wPuV9Fd7c63wyNPvPr6HmIlSkEhm5MFpOR2KBzZdS44RW1vhOOiBORfbOAaxkf9 43cpSiAA3+j+k+1LH9e6PJ27DN4PoOc5N43dHULbKKt4rPXKL/rARSFG6Jqwo/pLwojRgP UjBY8Pd3WWKA== Original-Received: from elite.giraud ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 9852142b (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Fri, 14 Jan 2022 11:40:04 +0100 (CET) Received-SPF: pass client-ip=51.159.28.247; envelope-from=manuel@ledu-giraud.fr; helo=ledu-giraud.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:284738 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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=E2=84=A2. Best regards, --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-simplify-return-case-for-Findirect_function.patch >From 300db08a4d66814000e2d6eb373f931c37913954 Mon Sep 17 00:00:00 2001 From: Manuel Giraud 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; } /* Extract and set vector and string elements. */ -- 2.34.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-use-Findirect_function-more.patch >From 99658ecb6860185e0b3fdb8932de3a8b6f7e0f69 Mon Sep 17 00:00:00 2001 From: Manuel Giraud 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 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--