From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#45550: [PATCH] Factor out new function for readability in chartab.c Date: Wed, 30 Dec 2020 22:15:14 +0200 Message-ID: <83k0szhwz1.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1403"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 45550@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 30 21:16:24 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1kuhtQ-0000G6-14 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Dec 2020 21:16:24 +0100 Original-Received: from localhost ([::1]:51392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuhtP-0003Oe-3T for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Dec 2020 15:16:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuht4-0003OI-6d for bug-gnu-emacs@gnu.org; Wed, 30 Dec 2020 15:16:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kuht3-0002HE-Vw for bug-gnu-emacs@gnu.org; Wed, 30 Dec 2020 15:16:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kuht3-0005J7-Qs for bug-gnu-emacs@gnu.org; Wed, 30 Dec 2020 15:16:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Dec 2020 20:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45550 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 45550-submit@debbugs.gnu.org id=B45550.160935932920356 (code B ref 45550); Wed, 30 Dec 2020 20:16:01 +0000 Original-Received: (at 45550) by debbugs.gnu.org; 30 Dec 2020 20:15:29 +0000 Original-Received: from localhost ([127.0.0.1]:51120 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kuhsW-0005IG-Uk for submit@debbugs.gnu.org; Wed, 30 Dec 2020 15:15:29 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:56602) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kuhsV-0005I4-1w for 45550@debbugs.gnu.org; Wed, 30 Dec 2020 15:15:27 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:33855) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuhsP-0001sD-Kw; Wed, 30 Dec 2020 15:15:21 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3122 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kuhsN-0005vs-VD; Wed, 30 Dec 2020 15:15:20 -0500 In-Reply-To: (message from Stefan Kangas on Wed, 30 Dec 2020 02:56:53 -0600) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:197044 Archived-At: > From: Stefan Kangas > Date: Wed, 30 Dec 2020 02:56:53 -0600 > > While poking around, I found an opportunity for refactoring in > charctab.c. I find it makes these functions significantly easier to > read and understand. > > Please see the attached patch. Thanks, I have a couple of comments: > +static Lisp_Object > +sub_char_table_ref_and_range (Lisp_Object, int, int *, int *, > + Lisp_Object, bool); There should be no need to declare a static function which is defined before it is used. > +static Lisp_Object > +char_table_ref_simple (Lisp_Object table, int idx, int c, int *from, int *to, > + Lisp_Object defalt, bool is_uniprop, bool is_subtable) > +{ > + Lisp_Object val = is_subtable ? > + XSUB_CHAR_TABLE (table)->contents[idx]: > + XCHAR_TABLE (table)->contents[idx]; > + if (is_uniprop && UNIPROP_COMPRESSED_FORM_P (val)) > + val = uniprop_table_uncompress (table, idx); > + if (SUB_CHAR_TABLE_P (val)) > + val = sub_char_table_ref_and_range (val, c, from, to, > + defalt, is_uniprop); > + else if (NILP (val)) > + val = defalt; > + return val; > +} > + Please make this a macro, not a function. The code you are factoring out is called in the innermost loops of the display engine, in bidi.c, so it must be as fast as possible, even in an unoptimized build, where static functions aren't inlined.