diff options
| author | Paul Eggert | 2018-06-28 00:37:08 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-06-28 00:42:46 -0700 |
| commit | 76eda952b09db6d79342b7ddfcae45c7c836ab62 (patch) | |
| tree | c1283adb00332f30c98e46da61e427057948aacc /src/doc.c | |
| parent | 79f6911bf1f6262c723f5a3602c2f80cbe63cf54 (diff) | |
| download | emacs-76eda952b09db6d79342b7ddfcae45c7c836ab62.tar.gz emacs-76eda952b09db6d79342b7ddfcae45c7c836ab62.zip | |
Tune SAFE_FREE
On my platform (Fedora 28 x86-64, AMD Phenom II X4 910e) this sped
up a SAFE_FREE-using microbenchmark (string-distance "abc" "abc")
by about 18%, and shrank the Emacs text size by about 0.1%.
* src/callint.c (Fcall_interactively):
* src/callproc.c (call_process):
* src/doc.c (get_doc_string, Fsnarf_documentation):
* src/editfns.c (Freplace_buffer_contents):
* src/emacs-module.c (funcall_module):
* src/eval.c (Flet):
* src/process.c (Fmake_process):
* src/term.c (tty_menu_show):
* src/xdisp.c (safe__call):
* src/xmenu.c (x_menu_show):
Use SAFE_FREE_UNBIND_TO.
* src/data.c (wrong_choice): No need to call SAFE_FREE here.
* src/lisp.h (USE_SAFE_ALLOCA):
* src/regex.c (REGEX_USE_SAFE_ALLOCA):
Do not declare sa_must_free local; no longer needed.
All uses removed.
(SAFE_FREE): Rewrite in terms of safe_free.
(safe_free): New function, optimized to use xfree.
(SAFE_FREE_UNBIND_TO): New macro.
(safe_free_unbind_to): New function.
Diffstat (limited to 'src/doc.c')
| -rw-r--r-- | src/doc.c | 9 |
1 files changed, 3 insertions, 6 deletions
| @@ -86,7 +86,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) | |||
| 86 | int offset; | 86 | int offset; |
| 87 | EMACS_INT position; | 87 | EMACS_INT position; |
| 88 | Lisp_Object file, tem, pos; | 88 | Lisp_Object file, tem, pos; |
| 89 | ptrdiff_t count; | 89 | ptrdiff_t count = SPECPDL_INDEX (); |
| 90 | USE_SAFE_ALLOCA; | 90 | USE_SAFE_ALLOCA; |
| 91 | 91 | ||
| 92 | if (INTEGERP (filepos)) | 92 | if (INTEGERP (filepos)) |
| @@ -148,7 +148,6 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) | |||
| 148 | return concat3 (cannot_open, file, quote_nl); | 148 | return concat3 (cannot_open, file, quote_nl); |
| 149 | } | 149 | } |
| 150 | } | 150 | } |
| 151 | count = SPECPDL_INDEX (); | ||
| 152 | record_unwind_protect_int (close_file_unwind, fd); | 151 | record_unwind_protect_int (close_file_unwind, fd); |
| 153 | 152 | ||
| 154 | /* Seek only to beginning of disk block. */ | 153 | /* Seek only to beginning of disk block. */ |
| @@ -204,8 +203,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) | |||
| 204 | } | 203 | } |
| 205 | p += nread; | 204 | p += nread; |
| 206 | } | 205 | } |
| 207 | unbind_to (count, Qnil); | 206 | SAFE_FREE_UNBIND_TO (count, Qnil); |
| 208 | SAFE_FREE (); | ||
| 209 | 207 | ||
| 210 | /* Sanity checking. */ | 208 | /* Sanity checking. */ |
| 211 | if (CONSP (filepos)) | 209 | if (CONSP (filepos)) |
| @@ -659,8 +657,7 @@ the same file name is found in the `doc-directory'. */) | |||
| 659 | memmove (buf, end, filled); | 657 | memmove (buf, end, filled); |
| 660 | } | 658 | } |
| 661 | 659 | ||
| 662 | SAFE_FREE (); | 660 | return SAFE_FREE_UNBIND_TO (count, Qnil); |
| 663 | return unbind_to (count, Qnil); | ||
| 664 | } | 661 | } |
| 665 | 662 | ||
| 666 | /* Return true if text quoting style should default to quote `like this'. */ | 663 | /* Return true if text quoting style should default to quote `like this'. */ |