diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2011-06-16 10:44:43 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-06-16 10:44:43 -0700 |
commit | 21d890a4ecf97141f3c3f7e373bca6d083662a83 (patch) | |
tree | cf72e75e1867e4da6da15e97d3555e55712c4624 /src/editfns.c | |
parent | 2e6813b0a503b14034783e12f704f7f70a47bae0 (diff) | |
download | emacs-21d890a4ecf97141f3c3f7e373bca6d083662a83.tar.gz emacs-21d890a4ecf97141f3c3f7e373bca6d083662a83.tar.bz2 emacs-21d890a4ecf97141f3c3f7e373bca6d083662a83.zip |
* editfns.c: Tune. Don't use wider integers than needed. Don't use alloca.
Use a bigger 'string' buffer. Rewrite to avoid 'n > 0' test.
Diffstat (limited to 'src/editfns.c')
-rw-r--r-- | src/editfns.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/editfns.c b/src/editfns.c index ab17eda86a9..2d736bbc7e2 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -2328,12 +2328,11 @@ The optional third arg INHERIT, if non-nil, says to inherit text properties from adjoining text, if those properties are sticky. */) (Lisp_Object character, Lisp_Object count, Lisp_Object inherit) { - register char *string; - register EMACS_INT stringlen; - register int i; + int i, stringlen; register EMACS_INT n; int c, len; unsigned char str[MAX_MULTIBYTE_LENGTH]; + char string[4000]; CHECK_CHARACTER (character); CHECK_NUMBER (count); @@ -2348,11 +2347,10 @@ from adjoining text, if those properties are sticky. */) if (BUF_BYTES_MAX / len < XINT (count)) buffer_overflow (); n = XINT (count) * len; - stringlen = min (n, 256 * len); - string = (char *) alloca (stringlen); + stringlen = min (n, sizeof string - sizeof string % len); for (i = 0; i < stringlen; i++) string[i] = str[i % len]; - while (n >= stringlen) + while (n > stringlen) { QUIT; if (!NILP (inherit)) @@ -2361,13 +2359,10 @@ from adjoining text, if those properties are sticky. */) insert (string, stringlen); n -= stringlen; } - if (n > 0) - { - if (!NILP (inherit)) - insert_and_inherit (string, n); - else - insert (string, n); - } + if (!NILP (inherit)) + insert_and_inherit (string, n); + else + insert (string, n); return Qnil; } |