aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-09-23 19:49:00 +0400
committerDmitry Antipov2014-09-23 19:49:00 +0400
commit59e10fbd934323702a4586f50139d58db846bbf1 (patch)
tree194db3962ed3b518afc92eed10ed16c29f6e0b15 /src
parentc03d2c89fbf878575cc46011df44f04103d8e19b (diff)
downloademacs-59e10fbd934323702a4586f50139d58db846bbf1.tar.gz
emacs-59e10fbd934323702a4586f50139d58db846bbf1.zip
Use known length of a Lisp string to copy it faster.
* lisp.h (lispstrcpy): New function. Add comment. * callproc.c (child_setup): * dbusbind.c (xd_append_arg): * doc.c (get_doc_string): * font.c (Ffont_xlfd_name): * frame.c (xrdb_get_resource): * process.c (Fmake_network_process, network_interface_info): * w32fns.c (Fx_open_connection): * w32proc.c (sys_spawnve): * xfns.c (select_visual): * xfont.c (xfont_list): * xsmfns.c (x_session_initialize): * xterm.c (x_term_init): Use it.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog19
-rw-r--r--src/callproc.c2
-rw-r--r--src/dbusbind.c2
-rw-r--r--src/doc.c2
-rw-r--r--src/font.c2
-rw-r--r--src/frame.c4
-rw-r--r--src/lisp.h9
-rw-r--r--src/process.c4
-rw-r--r--src/w32fns.c2
-rw-r--r--src/w32proc.c2
-rw-r--r--src/xfns.c2
-rw-r--r--src/xfont.c2
-rw-r--r--src/xsmfns.c2
-rw-r--r--src/xterm.c2
14 files changed, 41 insertions, 15 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 02d7871e884..63d732c8d2c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,7 +1,24 @@
12014-09-23 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Use known length of a Lisp string to copy it faster.
4 * lisp.h (lispstrcpy): New function. Add comment.
5 * callproc.c (child_setup):
6 * dbusbind.c (xd_append_arg):
7 * doc.c (get_doc_string):
8 * font.c (Ffont_xlfd_name):
9 * frame.c (xrdb_get_resource):
10 * process.c (Fmake_network_process, network_interface_info):
11 * w32fns.c (Fx_open_connection):
12 * w32proc.c (sys_spawnve):
13 * xfns.c (select_visual):
14 * xfont.c (xfont_list):
15 * xsmfns.c (x_session_initialize):
16 * xterm.c (x_term_init): Use it.
17
12014-09-23 Paul Eggert <eggert@cs.ucla.edu> 182014-09-23 Paul Eggert <eggert@cs.ucla.edu>
2 19
3 Fix SAFE_ALLOCA to not exhaust the stack when in a loop. 20 Fix SAFE_ALLOCA to not exhaust the stack when in a loop.
4 Problem reported by Dmietry Antipov in thread leading to: 21 Problem reported by Dmitry Antipov in thread leading to:
5 http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00713.html 22 http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00713.html
6 This patch fixes only SAFE_ALLOCA, SAFE_NALLOCA, and SAFE_ALLOCA_LISP; 23 This patch fixes only SAFE_ALLOCA, SAFE_NALLOCA, and SAFE_ALLOCA_LISP;
7 the experimental local_* macros enabled by USE_LOCAL_ALLOCATORS 24 the experimental local_* macros enabled by USE_LOCAL_ALLOCATORS
diff --git a/src/callproc.c b/src/callproc.c
index 4bedf671e83..2fa475e72df 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1235,7 +1235,7 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1235#endif 1235#endif
1236 temp = pwd_var + 4; 1236 temp = pwd_var + 4;
1237 memcpy (pwd_var, "PWD=", 4); 1237 memcpy (pwd_var, "PWD=", 4);
1238 strcpy (temp, SSDATA (current_dir)); 1238 lispstrcpy (temp, current_dir);
1239 1239
1240#ifndef DOS_NT 1240#ifndef DOS_NT
1241 /* We can't signal an Elisp error here; we're in a vfork. Since 1241 /* We can't signal an Elisp error here; we're in a vfork. Since
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 8997e01b068..58302df4927 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -761,7 +761,7 @@ xd_append_arg (int dtype, Lisp_Object object, DBusMessageIter *iter)
761 && STRINGP (CAR_SAFE (XD_NEXT_VALUE (object))) 761 && STRINGP (CAR_SAFE (XD_NEXT_VALUE (object)))
762 && NILP (CDR_SAFE (XD_NEXT_VALUE (object)))) 762 && NILP (CDR_SAFE (XD_NEXT_VALUE (object))))
763 { 763 {
764 strcpy (signature, SSDATA (CAR_SAFE (XD_NEXT_VALUE (object)))); 764 lispstrcpy (signature, CAR_SAFE (XD_NEXT_VALUE (object)));
765 object = CDR_SAFE (XD_NEXT_VALUE (object)); 765 object = CDR_SAFE (XD_NEXT_VALUE (object));
766 } 766 }
767 767
diff --git a/src/doc.c b/src/doc.c
index 98f2f8563a1..da6a9deb977 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -121,7 +121,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
121 if (minsize < 8) 121 if (minsize < 8)
122 minsize = 8; 122 minsize = 8;
123 name = SAFE_ALLOCA (minsize + SCHARS (file) + 8); 123 name = SAFE_ALLOCA (minsize + SCHARS (file) + 8);
124 strcpy (name, SSDATA (docdir)); 124 lispstrcpy (name, docdir);
125 strcat (name, SSDATA (file)); 125 strcat (name, SSDATA (file));
126 } 126 }
127 else 127 else
diff --git a/src/font.c b/src/font.c
index 83860090820..e8a13b7eeda 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4266,7 +4266,7 @@ the consecutive wildcards are folded into one. */)
4266 { 4266 {
4267 if (NILP (fold_wildcards)) 4267 if (NILP (fold_wildcards))
4268 return font_name; 4268 return font_name;
4269 strcpy (name, SSDATA (font_name)); 4269 lispstrcpy (name, font_name);
4270 namelen = SBYTES (font_name); 4270 namelen = SBYTES (font_name);
4271 goto done; 4271 goto done;
4272 } 4272 }
diff --git a/src/frame.c b/src/frame.c
index d56b11d962c..51bd8fa7cfc 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -4036,8 +4036,8 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Li
4036 4036
4037 /* Start with emacs.FRAMENAME for the name (the specific one) 4037 /* Start with emacs.FRAMENAME for the name (the specific one)
4038 and with `Emacs' for the class key (the general one). */ 4038 and with `Emacs' for the class key (the general one). */
4039 strcpy (name_key, SSDATA (Vx_resource_name)); 4039 lispstrcpy (name_key, Vx_resource_name);
4040 strcpy (class_key, SSDATA (Vx_resource_class)); 4040 lispstrcpy (class_key, Vx_resource_class);
4041 4041
4042 strcat (class_key, "."); 4042 strcat (class_key, ".");
4043 strcat (class_key, SSDATA (class)); 4043 strcat (class_key, SSDATA (class));
diff --git a/src/lisp.h b/src/lisp.h
index 21f652b81ac..6ece4810b0b 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4462,6 +4462,15 @@ extern void *xpalloc (void *, ptrdiff_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t);
4462extern char *xstrdup (const char *) ATTRIBUTE_MALLOC; 4462extern char *xstrdup (const char *) ATTRIBUTE_MALLOC;
4463extern char *xlispstrdup (Lisp_Object) ATTRIBUTE_MALLOC; 4463extern char *xlispstrdup (Lisp_Object) ATTRIBUTE_MALLOC;
4464extern void dupstring (char **, char const *); 4464extern void dupstring (char **, char const *);
4465
4466/* Like strcpy but uses known length of a Lisp string. */
4467
4468INLINE char *
4469lispstrcpy (const char *dest, Lisp_Object string)
4470{
4471 return memcpy ((void *) dest, SSDATA (string), SBYTES (string) + 1);
4472}
4473
4465extern void xputenv (const char *); 4474extern void xputenv (const char *);
4466 4475
4467extern char *egetenv_internal (const char *, ptrdiff_t); 4476extern char *egetenv_internal (const char *, ptrdiff_t);
diff --git a/src/process.c b/src/process.c
index 0807939dd25..c6140083784 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2989,7 +2989,7 @@ usage: (make-network-process &rest ARGS) */)
2989 address_un.sun_family = AF_LOCAL; 2989 address_un.sun_family = AF_LOCAL;
2990 if (sizeof address_un.sun_path <= SBYTES (service)) 2990 if (sizeof address_un.sun_path <= SBYTES (service))
2991 error ("Service name too long"); 2991 error ("Service name too long");
2992 strcpy (address_un.sun_path, SSDATA (service)); 2992 lispstrcpy (address_un.sun_path, service);
2993 ai.ai_addr = (struct sockaddr *) &address_un; 2993 ai.ai_addr = (struct sockaddr *) &address_un;
2994 ai.ai_addrlen = sizeof address_un; 2994 ai.ai_addrlen = sizeof address_un;
2995 goto open_socket; 2995 goto open_socket;
@@ -3680,7 +3680,7 @@ network_interface_info (Lisp_Object ifname)
3680 3680
3681 if (sizeof rq.ifr_name <= SBYTES (ifname)) 3681 if (sizeof rq.ifr_name <= SBYTES (ifname))
3682 error ("interface name too long"); 3682 error ("interface name too long");
3683 strcpy (rq.ifr_name, SSDATA (ifname)); 3683 lispstrcpy (rq.ifr_name, ifname);
3684 3684
3685 s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); 3685 s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
3686 if (s < 0) 3686 if (s < 0)
diff --git a/src/w32fns.c b/src/w32fns.c
index fee80d24690..a58a9ced85c 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -5339,7 +5339,7 @@ terminate Emacs if we can't open the connection.
5339 { 5339 {
5340 char basename[ MAX_PATH ], *str; 5340 char basename[ MAX_PATH ], *str;
5341 5341
5342 strcpy (basename, SDATA (Vinvocation_name)); 5342 lispstrcpy (basename, Vinvocation_name);
5343 str = strrchr (basename, '.'); 5343 str = strrchr (basename, '.');
5344 if (str) *str = 0; 5344 if (str) *str = 0;
5345 Vinvocation_name = build_string (basename); 5345 Vinvocation_name = build_string (basename);
diff --git a/src/w32proc.c b/src/w32proc.c
index 96f94a116af..795df31c858 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1647,7 +1647,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
1647 strcpy (cmdname, egetenv ("CMDPROXY")); 1647 strcpy (cmdname, egetenv ("CMDPROXY"));
1648 else 1648 else
1649 { 1649 {
1650 strcpy (cmdname, SDATA (Vinvocation_directory)); 1650 lispstrcpy (cmdname, Vinvocation_directory);
1651 strcat (cmdname, "cmdproxy.exe"); 1651 strcat (cmdname, "cmdproxy.exe");
1652 } 1652 }
1653 1653
diff --git a/src/xfns.c b/src/xfns.c
index b107f6e688c..7ecd15aea91 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4289,7 +4289,7 @@ select_visual (struct x_display_info *dpyinfo)
4289 int i, class = -1; 4289 int i, class = -1;
4290 XVisualInfo vinfo; 4290 XVisualInfo vinfo;
4291 4291
4292 strcpy (s, SSDATA (value)); 4292 lispstrcpy (s, value);
4293 dash = strchr (s, '-'); 4293 dash = strchr (s, '-');
4294 if (dash) 4294 if (dash)
4295 { 4295 {
diff --git a/src/xfont.c b/src/xfont.c
index 90b69ad5187..db0449716ab 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -541,7 +541,7 @@ xfont_list (struct frame *f, Lisp_Object spec)
541 if (STRINGP (XCAR (alter)) 541 if (STRINGP (XCAR (alter))
542 && ((r - name) + SBYTES (XCAR (alter))) < 256) 542 && ((r - name) + SBYTES (XCAR (alter))) < 256)
543 { 543 {
544 strcpy (r, SSDATA (XCAR (alter))); 544 lispstrcpy (r, XCAR (alter));
545 list = xfont_list_pattern (display, name, registry, script); 545 list = xfont_list_pattern (display, name, registry, script);
546 if (! NILP (list)) 546 if (! NILP (list))
547 break; 547 break;
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 8721cc81b03..5efbfaafa8f 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -418,7 +418,7 @@ x_session_initialize (struct x_display_info *dpyinfo)
418 emacs_program[0] = '\0'; 418 emacs_program[0] = '\0';
419 419
420 if (! EQ (Vinvocation_directory, Qnil)) 420 if (! EQ (Vinvocation_directory, Qnil))
421 strcpy (emacs_program, SSDATA (Vinvocation_directory)); 421 lispstrcpy (emacs_program, Vinvocation_directory);
422 strcat (emacs_program, SSDATA (Vinvocation_name)); 422 strcat (emacs_program, SSDATA (Vinvocation_name));
423 423
424 /* The SM protocol says all callbacks are mandatory, so set up all 424 /* The SM protocol says all callbacks are mandatory, so set up all
diff --git a/src/xterm.c b/src/xterm.c
index 4b4349d2622..1b721b042be 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10902,7 +10902,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10902 dpyinfo->x_id = ++x_display_id; 10902 dpyinfo->x_id = ++x_display_id;
10903 dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name) 10903 dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name)
10904 + SBYTES (Vsystem_name) + 2); 10904 + SBYTES (Vsystem_name) + 2);
10905 strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"), 10905 strcat (strcat (lispstrcpy (dpyinfo->x_id_name, Vinvocation_name), "@"),
10906 SSDATA (Vsystem_name)); 10906 SSDATA (Vsystem_name));
10907 10907
10908 /* Figure out which modifier bits mean what. */ 10908 /* Figure out which modifier bits mean what. */