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/editfns.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/editfns.c')
| -rw-r--r-- | src/editfns.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/editfns.c b/src/editfns.c index 7d032a7ca4c..88dfba1f910 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3198,6 +3198,8 @@ differences between the two buffers. */) | |||
| 3198 | return Qnil; | 3198 | return Qnil; |
| 3199 | } | 3199 | } |
| 3200 | 3200 | ||
| 3201 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 3202 | |||
| 3201 | /* FIXME: It is not documented how to initialize the contents of the | 3203 | /* FIXME: It is not documented how to initialize the contents of the |
| 3202 | context structure. This code cargo-cults from the existing | 3204 | context structure. This code cargo-cults from the existing |
| 3203 | caller in src/analyze.c of GNU Diffutils, which appears to | 3205 | caller in src/analyze.c of GNU Diffutils, which appears to |
| @@ -3231,7 +3233,6 @@ differences between the two buffers. */) | |||
| 3231 | eassert (! early_abort); | 3233 | eassert (! early_abort); |
| 3232 | 3234 | ||
| 3233 | Fundo_boundary (); | 3235 | Fundo_boundary (); |
| 3234 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 3235 | record_unwind_protect_excursion (); | 3236 | record_unwind_protect_excursion (); |
| 3236 | 3237 | ||
| 3237 | ptrdiff_t i = size_a; | 3238 | ptrdiff_t i = size_a; |
| @@ -3279,10 +3280,8 @@ differences between the two buffers. */) | |||
| 3279 | --i; | 3280 | --i; |
| 3280 | --j; | 3281 | --j; |
| 3281 | } | 3282 | } |
| 3282 | unbind_to (count, Qnil); | ||
| 3283 | SAFE_FREE (); | ||
| 3284 | 3283 | ||
| 3285 | return Qnil; | 3284 | return SAFE_FREE_UNBIND_TO (count, Qnil); |
| 3286 | } | 3285 | } |
| 3287 | 3286 | ||
| 3288 | static void | 3287 | static void |
| @@ -4885,7 +4884,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) | |||
| 4885 | if (buf == initial_buffer) | 4884 | if (buf == initial_buffer) |
| 4886 | { | 4885 | { |
| 4887 | buf = xmalloc (bufsize); | 4886 | buf = xmalloc (bufsize); |
| 4888 | sa_must_free = true; | ||
| 4889 | buf_save_value_index = SPECPDL_INDEX (); | 4887 | buf_save_value_index = SPECPDL_INDEX (); |
| 4890 | record_unwind_protect_ptr (xfree, buf); | 4888 | record_unwind_protect_ptr (xfree, buf); |
| 4891 | memcpy (buf, initial_buffer, used); | 4889 | memcpy (buf, initial_buffer, used); |