diff options
| author | Paul Eggert | 2019-07-11 23:06:22 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-07-11 23:07:22 -0700 |
| commit | 81a1088ee8b833cd30a3363782195d6c4d575672 (patch) | |
| tree | bad0854f81fd608d667259bbc68afc619c49f9f1 /lib-src | |
| parent | 77a4cc9f1a7df97c9a11195dcf6e90c8820be9bb (diff) | |
| download | emacs-81a1088ee8b833cd30a3363782195d6c4d575672.tar.gz emacs-81a1088ee8b833cd30a3363782195d6c4d575672.zip | |
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.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/make-docfile.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 4d25b0a6b93..368150be067 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) | |||
| 641 | return ga->type - gb->type; | 641 | return ga->type - gb->type; |
| 642 | 642 | ||
| 643 | /* Consider "nil" to be the least, so that iQnil is zero. That | 643 | /* Consider "nil" to be the least, so that iQnil is zero. That |
| 644 | way, Qnil's internal representation is zero, which is a bit faster. */ | 644 | way, Qnil's internal representation is zero, which is a bit faster. |
| 645 | Similarly, consideer "t" to be the second-least, and so forth. */ | ||
| 645 | if (ga->type == SYMBOL) | 646 | if (ga->type == SYMBOL) |
| 646 | { | 647 | { |
| 647 | bool a_nil = strcmp (ga->name, "Qnil") == 0; | 648 | /* Common symbols in decreasing popularity order. */ |
| 648 | bool b_nil = strcmp (gb->name, "Qnil") == 0; | 649 | static char const commonsym[][8] |
| 649 | if (a_nil | b_nil) | 650 | = { "nil", "t", "unbound", "error", "lambda" }; |
| 650 | return b_nil - a_nil; | 651 | int ncommonsym = sizeof commonsym / sizeof *commonsym; |
| 652 | int ai = ncommonsym, bi = ncommonsym; | ||
| 653 | for (int i = 0; i < ncommonsym; i++) | ||
| 654 | { | ||
| 655 | if (ga->name[0] == 'Q' && strcmp (ga->name + 1, commonsym[i]) == 0) | ||
| 656 | ai = i; | ||
| 657 | if (gb->name[0] == 'Q' && strcmp (gb->name + 1, commonsym[i]) == 0) | ||
| 658 | bi = i; | ||
| 659 | } | ||
| 660 | if (! (ai == ncommonsym && bi == ncommonsym)) | ||
| 661 | return ai - bi; | ||
| 651 | } | 662 | } |
| 652 | 663 | ||
| 653 | return strcmp (ga->name, gb->name); | 664 | return strcmp (ga->name, gb->name); |