[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r117926: Use known length of a Lisp string to copy i
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] trunk r117926: Use known length of a Lisp string to copy it faster. |
Date: |
Tue, 23 Sep 2014 15:49:12 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 117926
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Tue 2014-09-23 19:49:00 +0400
message:
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.
modified:
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/callproc.c callproc.c-20091113204419-o5vbwnq5f7feedwu-248
src/dbusbind.c dbusbind.c-20091113204419-o5vbwnq5f7feedwu-7961
src/doc.c doc.c-20091113204419-o5vbwnq5f7feedwu-250
src/font.c font.c-20091113204419-o5vbwnq5f7feedwu-8540
src/frame.c frame.c-20091113204419-o5vbwnq5f7feedwu-243
src/lisp.h lisp.h-20091113204419-o5vbwnq5f7feedwu-253
src/process.c process.c-20091113204419-o5vbwnq5f7feedwu-462
src/w32fns.c w32fns.c-20091113204419-o5vbwnq5f7feedwu-945
src/w32proc.c w32proc.c-20091113204419-o5vbwnq5f7feedwu-814
src/xfns.c xfns.c-20091113204419-o5vbwnq5f7feedwu-274
src/xfont.c xfont.c-20091113204419-o5vbwnq5f7feedwu-8547
src/xsmfns.c xsmfns.c-20091113204419-o5vbwnq5f7feedwu-2385
src/xterm.c xterm.c-20091113204419-o5vbwnq5f7feedwu-244
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2014-09-23 05:42:47 +0000
+++ b/src/ChangeLog 2014-09-23 15:49:00 +0000
@@ -1,7 +1,24 @@
+2014-09-23 Dmitry Antipov <address@hidden>
+
+ 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.
+
2014-09-23 Paul Eggert <address@hidden>
Fix SAFE_ALLOCA to not exhaust the stack when in a loop.
- Problem reported by Dmietry Antipov in thread leading to:
+ Problem reported by Dmitry Antipov in thread leading to:
http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00713.html
This patch fixes only SAFE_ALLOCA, SAFE_NALLOCA, and SAFE_ALLOCA_LISP;
the experimental local_* macros enabled by USE_LOCAL_ALLOCATORS
=== modified file 'src/callproc.c'
--- a/src/callproc.c 2014-09-23 05:42:47 +0000
+++ b/src/callproc.c 2014-09-23 15:49:00 +0000
@@ -1235,7 +1235,7 @@
#endif
temp = pwd_var + 4;
memcpy (pwd_var, "PWD=", 4);
- strcpy (temp, SSDATA (current_dir));
+ lispstrcpy (temp, current_dir);
#ifndef DOS_NT
/* We can't signal an Elisp error here; we're in a vfork. Since
=== modified file 'src/dbusbind.c'
--- a/src/dbusbind.c 2014-05-20 08:25:18 +0000
+++ b/src/dbusbind.c 2014-09-23 15:49:00 +0000
@@ -761,7 +761,7 @@
&& STRINGP (CAR_SAFE (XD_NEXT_VALUE (object)))
&& NILP (CDR_SAFE (XD_NEXT_VALUE (object))))
{
- strcpy (signature, SSDATA (CAR_SAFE (XD_NEXT_VALUE (object))));
+ lispstrcpy (signature, CAR_SAFE (XD_NEXT_VALUE (object)));
object = CDR_SAFE (XD_NEXT_VALUE (object));
}
=== modified file 'src/doc.c'
--- a/src/doc.c 2014-09-15 14:53:23 +0000
+++ b/src/doc.c 2014-09-23 15:49:00 +0000
@@ -121,7 +121,7 @@
if (minsize < 8)
minsize = 8;
name = SAFE_ALLOCA (minsize + SCHARS (file) + 8);
- strcpy (name, SSDATA (docdir));
+ lispstrcpy (name, docdir);
strcat (name, SSDATA (file));
}
else
=== modified file 'src/font.c'
--- a/src/font.c 2014-09-22 19:20:45 +0000
+++ b/src/font.c 2014-09-23 15:49:00 +0000
@@ -4266,7 +4266,7 @@
{
if (NILP (fold_wildcards))
return font_name;
- strcpy (name, SSDATA (font_name));
+ lispstrcpy (name, font_name);
namelen = SBYTES (font_name);
goto done;
}
=== modified file 'src/frame.c'
--- a/src/frame.c 2014-09-22 19:20:45 +0000
+++ b/src/frame.c 2014-09-23 15:49:00 +0000
@@ -4036,8 +4036,8 @@
/* Start with emacs.FRAMENAME for the name (the specific one)
and with `Emacs' for the class key (the general one). */
- strcpy (name_key, SSDATA (Vx_resource_name));
- strcpy (class_key, SSDATA (Vx_resource_class));
+ lispstrcpy (name_key, Vx_resource_name);
+ lispstrcpy (class_key, Vx_resource_class);
strcat (class_key, ".");
strcat (class_key, SSDATA (class));
=== modified file 'src/lisp.h'
--- a/src/lisp.h 2014-09-23 05:42:47 +0000
+++ b/src/lisp.h 2014-09-23 15:49:00 +0000
@@ -4462,6 +4462,15 @@
extern char *xstrdup (const char *) ATTRIBUTE_MALLOC;
extern char *xlispstrdup (Lisp_Object) ATTRIBUTE_MALLOC;
extern void dupstring (char **, char const *);
+
+/* Like strcpy but uses known length of a Lisp string. */
+
+INLINE char *
+lispstrcpy (const char *dest, Lisp_Object string)
+{
+ return memcpy ((void *) dest, SSDATA (string), SBYTES (string) + 1);
+}
+
extern void xputenv (const char *);
extern char *egetenv_internal (const char *, ptrdiff_t);
=== modified file 'src/process.c'
--- a/src/process.c 2014-09-18 11:34:24 +0000
+++ b/src/process.c 2014-09-23 15:49:00 +0000
@@ -2989,7 +2989,7 @@
address_un.sun_family = AF_LOCAL;
if (sizeof address_un.sun_path <= SBYTES (service))
error ("Service name too long");
- strcpy (address_un.sun_path, SSDATA (service));
+ lispstrcpy (address_un.sun_path, service);
ai.ai_addr = (struct sockaddr *) &address_un;
ai.ai_addrlen = sizeof address_un;
goto open_socket;
@@ -3680,7 +3680,7 @@
if (sizeof rq.ifr_name <= SBYTES (ifname))
error ("interface name too long");
- strcpy (rq.ifr_name, SSDATA (ifname));
+ lispstrcpy (rq.ifr_name, ifname);
s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (s < 0)
=== modified file 'src/w32fns.c'
--- a/src/w32fns.c 2014-09-03 15:10:29 +0000
+++ b/src/w32fns.c 2014-09-23 15:49:00 +0000
@@ -5339,7 +5339,7 @@
{
char basename[ MAX_PATH ], *str;
- strcpy (basename, SDATA (Vinvocation_name));
+ lispstrcpy (basename, Vinvocation_name);
str = strrchr (basename, '.');
if (str) *str = 0;
Vinvocation_name = build_string (basename);
=== modified file 'src/w32proc.c'
--- a/src/w32proc.c 2014-09-01 15:07:17 +0000
+++ b/src/w32proc.c 2014-09-23 15:49:00 +0000
@@ -1647,7 +1647,7 @@
strcpy (cmdname, egetenv ("CMDPROXY"));
else
{
- strcpy (cmdname, SDATA (Vinvocation_directory));
+ lispstrcpy (cmdname, Vinvocation_directory);
strcat (cmdname, "cmdproxy.exe");
}
=== modified file 'src/xfns.c'
--- a/src/xfns.c 2014-09-18 11:34:24 +0000
+++ b/src/xfns.c 2014-09-23 15:49:00 +0000
@@ -4289,7 +4289,7 @@
int i, class = -1;
XVisualInfo vinfo;
- strcpy (s, SSDATA (value));
+ lispstrcpy (s, value);
dash = strchr (s, '-');
if (dash)
{
=== modified file 'src/xfont.c'
--- a/src/xfont.c 2014-09-18 11:34:24 +0000
+++ b/src/xfont.c 2014-09-23 15:49:00 +0000
@@ -541,7 +541,7 @@
if (STRINGP (XCAR (alter))
&& ((r - name) + SBYTES (XCAR (alter))) < 256)
{
- strcpy (r, SSDATA (XCAR (alter)));
+ lispstrcpy (r, XCAR (alter));
list = xfont_list_pattern (display, name, registry, script);
if (! NILP (list))
break;
=== modified file 'src/xsmfns.c'
--- a/src/xsmfns.c 2014-09-04 05:38:37 +0000
+++ b/src/xsmfns.c 2014-09-23 15:49:00 +0000
@@ -418,7 +418,7 @@
emacs_program[0] = '\0';
if (! EQ (Vinvocation_directory, Qnil))
- strcpy (emacs_program, SSDATA (Vinvocation_directory));
+ lispstrcpy (emacs_program, Vinvocation_directory);
strcat (emacs_program, SSDATA (Vinvocation_name));
/* The SM protocol says all callbacks are mandatory, so set up all
=== modified file 'src/xterm.c'
--- a/src/xterm.c 2014-09-22 19:20:45 +0000
+++ b/src/xterm.c 2014-09-23 15:49:00 +0000
@@ -10902,7 +10902,7 @@
dpyinfo->x_id = ++x_display_id;
dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name)
+ SBYTES (Vsystem_name) + 2);
- strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"),
+ strcat (strcat (lispstrcpy (dpyinfo->x_id_name, Vinvocation_name), "@"),
SSDATA (Vsystem_name));
/* Figure out which modifier bits mean what. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r117926: Use known length of a Lisp string to copy it faster.,
Dmitry Antipov <=