From: Paul Eggert Date: Sat, 18 Jun 2011 16:01:08 +0000 (-0700) Subject: * fns.c: Use much-faster test for byte-length change. X-Git-Tag: emacs-pretest-24.0.90~104^2~473^2~57 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f03dc6ef9f0c33552acea1713901de8c73f23b82;p=emacs.git * fns.c: Use much-faster test for byte-length change. --- diff --git a/src/ChangeLog b/src/ChangeLog index c47a6402e81..75b9327247c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,6 +1,7 @@ 2011-06-18 Paul Eggert * fns.c (Ffillarray): Don't assume bool vector size fits in 'int'. + Use much-faster test for byte-length change. * alloc.c (Fmake_bool_vector): Avoid unnecessary multiplication. diff --git a/src/fns.c b/src/fns.c index 7b303ff3836..c308e06101f 100644 --- a/src/fns.c +++ b/src/fns.c @@ -23,6 +23,8 @@ along with GNU Emacs. If not, see . */ #include #include +#include + #include "lisp.h" #include "commands.h" #include "character.h" @@ -2167,17 +2169,11 @@ ARRAY is a vector, string, char-table, or bool-vector. */) unsigned char str[MAX_MULTIBYTE_LENGTH]; int len = CHAR_STRING (charval, str); EMACS_INT size_byte = SBYTES (array); - unsigned char *p1 = p, *endp = p + size_byte; int i; - if (size != size_byte) - while (p1 < endp) - { - int this_len = BYTES_BY_CHAR_HEAD (*p1); - if (len != this_len) - error ("Attempt to change byte length of a string"); - p1 += this_len; - } + if (INT_MULTIPLY_OVERFLOW (SCHARS (array), len) + || SCHARS (array) * len != size_byte) + error ("Attempt to change byte length of a string"); for (i = 0; i < size_byte; i++) *p++ = str[i % len]; }