diff options
| author | Dmitry Antipov | 2012-07-10 12:43:46 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-10 12:43:46 +0400 |
| commit | 2a0213a6d0a9e36a388994445837e051d0bbe5f9 (patch) | |
| tree | b7e4d5c2ef5d4061e083ef2123c1fc72ad46d93d /src/alloc.c | |
| parent | cb1caeaf2ba26df05e8f9bcd4aa63203cef781fb (diff) | |
| download | emacs-2a0213a6d0a9e36a388994445837e051d0bbe5f9.tar.gz emacs-2a0213a6d0a9e36a388994445837e051d0bbe5f9.zip | |
Optimize pure C strings initialization.
* lisp.h (make_pure_string): Fix prototype.
(build_pure_c_string): New function, defined as static inline. This
provides a better opportunity to optimize away calls to strlen when
the function is called with compile-time constant argument.
* alloc.c (make_pure_c_string): Fix comment. Change to add nchars
argument, adjust users accordingly. Use build_pure_c_string where
appropriate.
* buffer.c, coding.c, data.c, dbusbind.c, fileio.c, fontset.c, frame.c,
* keyboard.c, keymap.c, lread.c, search.c, syntax.c, w32fns.c, xdisp.c,
* xfaces.c, xfns.c, xterm.c: Use build_pure_c_string where appropriate.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/alloc.c b/src/alloc.c index a5c2e20d0c9..52d683a1b67 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -5212,15 +5212,14 @@ make_pure_string (const char *data, | |||
| 5212 | return string; | 5212 | return string; |
| 5213 | } | 5213 | } |
| 5214 | 5214 | ||
| 5215 | /* Return a string a string allocated in pure space. Do not allocate | 5215 | /* Return a string allocated in pure space. Do not |
| 5216 | the string data, just point to DATA. */ | 5216 | allocate the string data, just point to DATA. */ |
| 5217 | 5217 | ||
| 5218 | Lisp_Object | 5218 | Lisp_Object |
| 5219 | make_pure_c_string (const char *data) | 5219 | make_pure_c_string (const char *data, ptrdiff_t nchars) |
| 5220 | { | 5220 | { |
| 5221 | Lisp_Object string; | 5221 | Lisp_Object string; |
| 5222 | struct Lisp_String *s; | 5222 | struct Lisp_String *s; |
| 5223 | ptrdiff_t nchars = strlen (data); | ||
| 5224 | 5223 | ||
| 5225 | s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); | 5224 | s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); |
| 5226 | s->size = nchars; | 5225 | s->size = nchars; |
| @@ -6842,7 +6841,7 @@ do hash-consing of the objects allocated to pure space. */); | |||
| 6842 | not be able to allocate the memory to hold it. */ | 6841 | not be able to allocate the memory to hold it. */ |
| 6843 | Vmemory_signal_data | 6842 | Vmemory_signal_data |
| 6844 | = pure_cons (Qerror, | 6843 | = pure_cons (Qerror, |
| 6845 | pure_cons (make_pure_c_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs"), Qnil)); | 6844 | pure_cons (build_pure_c_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs"), Qnil)); |
| 6846 | 6845 | ||
| 6847 | DEFVAR_LISP ("memory-full", Vmemory_full, | 6846 | DEFVAR_LISP ("memory-full", Vmemory_full, |
| 6848 | doc: /* Non-nil means Emacs cannot get much more Lisp memory. */); | 6847 | doc: /* Non-nil means Emacs cannot get much more Lisp memory. */); |