emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 81a1088: Tweak builtin symbol order for speed


From: Paul Eggert
Subject: [Emacs-diffs] master 81a1088: Tweak builtin symbol order for speed
Date: Fri, 12 Jul 2019 02:07:27 -0400 (EDT)

branch: master
commit 81a1088ee8b833cd30a3363782195d6c4d575672
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Tweak builtin symbol order for speed
    
    * lib-src/make-docfile.c (compare_globals):
    Make symbols 1 through 4 be t, unbound, error, lambda.
    This is in addition to symbol 0 being nil.
    This change improved ‘make compile-always’ performance by 0.6%
    on my platform.
---
 lib-src/make-docfile.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index 4d25b0a..368150b 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -641,13 +641,24 @@ compare_globals (const void *a, const void *b)
     return ga->type - gb->type;
 
   /* Consider "nil" to be the least, so that iQnil is zero.  That
-     way, Qnil's internal representation is zero, which is a bit faster.  */
+     way, Qnil's internal representation is zero, which is a bit faster.
+     Similarly, consideer "t" to be the second-least, and so forth.  */
   if (ga->type == SYMBOL)
     {
-      bool a_nil = strcmp (ga->name, "Qnil") == 0;
-      bool b_nil = strcmp (gb->name, "Qnil") == 0;
-      if (a_nil | b_nil)
-       return b_nil - a_nil;
+      /* Common symbols in decreasing popularity order.  */
+      static char const commonsym[][8]
+       = { "nil", "t", "unbound", "error", "lambda" };
+      int ncommonsym = sizeof commonsym / sizeof *commonsym;
+      int ai = ncommonsym, bi = ncommonsym;
+      for (int i = 0; i < ncommonsym; i++)
+       {
+         if (ga->name[0] == 'Q' && strcmp (ga->name + 1, commonsym[i]) == 0)
+           ai = i;
+         if (gb->name[0] == 'Q' && strcmp (gb->name + 1, commonsym[i]) == 0)
+           bi = i;
+       }
+      if (! (ai == ncommonsym && bi == ncommonsym))
+       return ai - bi;
     }
 
   return strcmp (ga->name, gb->name);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]