diff options
| author | Paul Eggert | 2011-06-18 09:01:08 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-18 09:01:08 -0700 |
| commit | f03dc6ef9f0c33552acea1713901de8c73f23b82 (patch) | |
| tree | 054528d21f6428d56b7bbeee26a8037733980006 /src | |
| parent | b4e50fa0d03ebc4a71f4d0057495ac2b8c391429 (diff) | |
| download | emacs-f03dc6ef9f0c33552acea1713901de8c73f23b82.tar.gz emacs-f03dc6ef9f0c33552acea1713901de8c73f23b82.zip | |
* fns.c: Use much-faster test for byte-length change.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 1 | ||||
| -rw-r--r-- | src/fns.c | 14 |
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 @@ | |||
| 1 | 2011-06-18 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-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 | ||
| @@ -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 | } |