aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-06-18 09:01:08 -0700
committerPaul Eggert2011-06-18 09:01:08 -0700
commitf03dc6ef9f0c33552acea1713901de8c73f23b82 (patch)
tree054528d21f6428d56b7bbeee26a8037733980006 /src
parentb4e50fa0d03ebc4a71f4d0057495ac2b8c391429 (diff)
downloademacs-f03dc6ef9f0c33552acea1713901de8c73f23b82.tar.gz
emacs-f03dc6ef9f0c33552acea1713901de8c73f23b82.zip
* fns.c: Use much-faster test for byte-length change.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog1
-rw-r--r--src/fns.c14
2 files changed, 6 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c47a6402e81..75b9327247c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,6 +1,7 @@
12011-06-18 Paul Eggert <eggert@cs.ucla.edu> 12011-06-18 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 * fns.c (Ffillarray): Don't assume bool vector size fits in 'int'. 3 * fns.c (Ffillarray): Don't assume bool vector size fits in 'int'.
4 Use much-faster test for byte-length change.
4 5
5 * alloc.c (Fmake_bool_vector): Avoid unnecessary multiplication. 6 * alloc.c (Fmake_bool_vector): Avoid unnecessary multiplication.
6 7
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 <http://www.gnu.org/licenses/>. */
23#include <time.h> 23#include <time.h>
24#include <setjmp.h> 24#include <setjmp.h>
25 25
26#include <intprops.h>
27
26#include "lisp.h" 28#include "lisp.h"
27#include "commands.h" 29#include "commands.h"
28#include "character.h" 30#include "character.h"
@@ -2167,17 +2169,11 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
2167 unsigned char str[MAX_MULTIBYTE_LENGTH]; 2169 unsigned char str[MAX_MULTIBYTE_LENGTH];
2168 int len = CHAR_STRING (charval, str); 2170 int len = CHAR_STRING (charval, str);
2169 EMACS_INT size_byte = SBYTES (array); 2171 EMACS_INT size_byte = SBYTES (array);
2170 unsigned char *p1 = p, *endp = p + size_byte;
2171 int i; 2172 int i;
2172 2173
2173 if (size != size_byte) 2174 if (INT_MULTIPLY_OVERFLOW (SCHARS (array), len)
2174 while (p1 < endp) 2175 || SCHARS (array) * len != size_byte)
2175 { 2176 error ("Attempt to change byte length of a string");
2176 int this_len = BYTES_BY_CHAR_HEAD (*p1);
2177 if (len != this_len)
2178 error ("Attempt to change byte length of a string");
2179 p1 += this_len;
2180 }
2181 for (i = 0; i < size_byte; i++) 2177 for (i = 0; i < size_byte; i++)
2182 *p++ = str[i % len]; 2178 *p++ = str[i % len];
2183 } 2179 }