diff options
| author | Glenn Morris | 2012-07-03 13:47:32 -0400 |
|---|---|---|
| committer | Glenn Morris | 2012-07-03 13:47:32 -0400 |
| commit | 8e4fd1e172f5fc3daf8219965a588bf0125ba311 (patch) | |
| tree | 0711359c39d358c71d6b81a03dafe6688ca3abbe /src | |
| parent | ca95b3ebc8587780966cee0acfe0f7822e895f83 (diff) | |
| download | emacs-8e4fd1e172f5fc3daf8219965a588bf0125ba311.tar.gz emacs-8e4fd1e172f5fc3daf8219965a588bf0125ba311.zip | |
Speed up generate-new-buffer-name for invisible buffers (bug#1229)
* src/buffer.c (Fgenerate_new_buffer_name):
Speed up finding a new buffer for invisible buffers.
* src/lisp.h (Frandom): Make it visible to C.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/buffer.c | 22 | ||||
| -rw-r--r-- | src/lisp.h | 1 |
3 files changed, 26 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index e3993981317..805b189ae83 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-07-03 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * lisp.h (Frandom): Make it visible to C. | ||
| 4 | * buffer.c (Fgenerate_new_buffer_name): Speed up finding a new | ||
| 5 | buffer for invisible buffers. (Bug#1229) | ||
| 6 | |||
| 1 | 2012-07-03 Dmitry Antipov <dmantipov@yandex.ru> | 7 | 2012-07-03 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 8 | ||
| 3 | Fix block vector allocation code to allow VECTOR_BLOCK_SIZE | 9 | Fix block vector allocation code to allow VECTOR_BLOCK_SIZE |
diff --git a/src/buffer.c b/src/buffer.c index 08118baa3d7..83f0eb153c5 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -838,10 +838,14 @@ If there is no live buffer named NAME, then return NAME. | |||
| 838 | Otherwise modify name by appending `<NUMBER>', incrementing NUMBER | 838 | Otherwise modify name by appending `<NUMBER>', incrementing NUMBER |
| 839 | \(starting at 2) until an unused name is found, and then return that name. | 839 | \(starting at 2) until an unused name is found, and then return that name. |
| 840 | Optional second argument IGNORE specifies a name that is okay to use (if | 840 | Optional second argument IGNORE specifies a name that is okay to use (if |
| 841 | it is in the sequence to be tried) even if a buffer with that name exists. */) | 841 | it is in the sequence to be tried) even if a buffer with that name exists. |
| 842 | |||
| 843 | If NAME begins with a space (i.e., a buffer that is not normally | ||
| 844 | visible to users), then if buffer NAME already exists a random number | ||
| 845 | is first appended to NAME, to speed up finding a non-existent buffer. */) | ||
| 842 | (register Lisp_Object name, Lisp_Object ignore) | 846 | (register Lisp_Object name, Lisp_Object ignore) |
| 843 | { | 847 | { |
| 844 | register Lisp_Object gentemp, tem; | 848 | register Lisp_Object gentemp, tem, tem2; |
| 845 | ptrdiff_t count; | 849 | ptrdiff_t count; |
| 846 | char number[INT_BUFSIZE_BOUND (ptrdiff_t) + sizeof "<>"]; | 850 | char number[INT_BUFSIZE_BOUND (ptrdiff_t) + sizeof "<>"]; |
| 847 | 851 | ||
| @@ -854,11 +858,23 @@ it is in the sequence to be tried) even if a buffer with that name exists. */) | |||
| 854 | if (NILP (tem)) | 858 | if (NILP (tem)) |
| 855 | return name; | 859 | return name; |
| 856 | 860 | ||
| 861 | if (!strncmp (SSDATA (name), " ", 1)) /* see bug#1229 */ | ||
| 862 | { | ||
| 863 | /* Note fileio.c:make_temp_name does random differently. */ | ||
| 864 | sprintf (number, "-%"pD"d", Frandom (make_number (999999))); | ||
| 865 | tem2 = concat2 (name, build_string (number)); | ||
| 866 | tem = Fget_buffer (tem2); | ||
| 867 | if (NILP (tem)) | ||
| 868 | return tem2; | ||
| 869 | } | ||
| 870 | else | ||
| 871 | tem2 = name; | ||
| 872 | |||
| 857 | count = 1; | 873 | count = 1; |
| 858 | while (1) | 874 | while (1) |
| 859 | { | 875 | { |
| 860 | sprintf (number, "<%"pD"d>", ++count); | 876 | sprintf (number, "<%"pD"d>", ++count); |
| 861 | gentemp = concat2 (name, build_string (number)); | 877 | gentemp = concat2 (tem2, build_string (number)); |
| 862 | tem = Fstring_equal (gentemp, ignore); | 878 | tem = Fstring_equal (gentemp, ignore); |
| 863 | if (!NILP (tem)) | 879 | if (!NILP (tem)) |
| 864 | return gentemp; | 880 | return gentemp; |
diff --git a/src/lisp.h b/src/lisp.h index 8cec1600692..2059e2a3fbd 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2473,6 +2473,7 @@ EXFUN (Fputhash, 3); | |||
| 2473 | EXFUN (Fremhash, 2); | 2473 | EXFUN (Fremhash, 2); |
| 2474 | 2474 | ||
| 2475 | EXFUN (Fidentity, 1); | 2475 | EXFUN (Fidentity, 1); |
| 2476 | EXFUN (Frandom, 1); | ||
| 2476 | EXFUN (Flength, 1); | 2477 | EXFUN (Flength, 1); |
| 2477 | EXFUN (Fappend, MANY); | 2478 | EXFUN (Fappend, MANY); |
| 2478 | EXFUN (Fconcat, MANY); | 2479 | EXFUN (Fconcat, MANY); |