summaryrefslogtreecommitdiff
path: root/src/doc.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2018-06-28 00:37:08 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2018-06-28 00:42:46 -0700
commit76eda952b09db6d79342b7ddfcae45c7c836ab62 (patch)
treec1283adb00332f30c98e46da61e427057948aacc /src/doc.c
parent79f6911bf1f6262c723f5a3602c2f80cbe63cf54 (diff)
downloademacs-76eda952b09db6d79342b7ddfcae45c7c836ab62.tar.gz
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.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/doc.c b/src/doc.c
index 4264ed50640..075154e94bc 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -86,7 +86,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
int offset;
EMACS_INT position;
Lisp_Object file, tem, pos;
- ptrdiff_t count;
+ ptrdiff_t count = SPECPDL_INDEX ();
USE_SAFE_ALLOCA;
if (INTEGERP (filepos))
@@ -148,7 +148,6 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
return concat3 (cannot_open, file, quote_nl);
}
}
- count = SPECPDL_INDEX ();
record_unwind_protect_int (close_file_unwind, fd);
/* Seek only to beginning of disk block. */
@@ -204,8 +203,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
}
p += nread;
}
- unbind_to (count, Qnil);
- SAFE_FREE ();
+ SAFE_FREE_UNBIND_TO (count, Qnil);
/* Sanity checking. */
if (CONSP (filepos))
@@ -659,8 +657,7 @@ the same file name is found in the `doc-directory'. */)
memmove (buf, end, filled);
}
- SAFE_FREE ();
- return unbind_to (count, Qnil);
+ return SAFE_FREE_UNBIND_TO (count, Qnil);
}
/* Return true if text quoting style should default to quote `like this'. */