]> code.delx.au - gnu-emacs/commitdiff
* src/alloc.c: Remove build_string.
authorDmitry Antipov <dmantipov@yandex.ru>
Tue, 26 Jun 2012 05:00:30 +0000 (09:00 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Tue, 26 Jun 2012 05:00:30 +0000 (09:00 +0400)
* src/lisp.h: Define build_string as static inline.  This provides
a better opportunity to optimize away calls to strlen when the
function is called with compile-time constant argument.
* src/image.c (imagemagick_error): Convert to build_string.
* src/w32proc.c (sys_spawnve): Likewise.
* src/xterm.c (x_term_init): Likewise.
* admin/coccinelle/build_string.cocci: Semantic patch
to convert from make_string to build_string.

admin/ChangeLog
admin/coccinelle/build_string.cocci [new file with mode: 0644]
src/ChangeLog
src/alloc.c
src/image.c
src/lisp.h
src/w32proc.c
src/xterm.c

index 44856f4b4499a71d9401a19b98e308b59a976c5a..d983bb0229ce22a3225e83b1b2de1e1738efc275 100644 (file)
@@ -1,3 +1,8 @@
+2012-06-26  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * coccinelle/build_string.cocci: Semantic patch
+       to convert from make_string to build_string.
+
 2012-06-24  Dmitry Antipov  <dmantipov@yandex.ru>
 
        First Coccinelle semantic patch.
diff --git a/admin/coccinelle/build_string.cocci b/admin/coccinelle/build_string.cocci
new file mode 100644 (file)
index 0000000..d477270
--- /dev/null
@@ -0,0 +1,6 @@
+// Convert simple cases to build_string.
+@@
+identifier I;
+@@
+- make_string (I, strlen (I))
++ build_string (I)
index 5b3387b81344dc4aae36a0b624192514fd5f5930..ff3fa02790e36252544aa36f4b87bf1c326bdcf7 100644 (file)
@@ -1,3 +1,13 @@
+2012-06-26  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * alloc.c: Remove build_string.
+       * lisp.h: Define build_string as static inline.  This provides
+       a better opportunity to optimize away calls to strlen when the
+       function is called with compile-time constant argument.
+       * image.c (imagemagick_error): Convert to build_string.
+       * w32proc.c (sys_spawnve): Likewise.
+       * xterm.c (x_term_init): Likewise.
+
 2012-06-26  Paul Eggert  <eggert@cs.ucla.edu>
 
        Use sprintf return value instead of invoking strlen on result.
index 490632f282f8c720e7460963d42846e76532c2f5..6f7cc968b81d6ae489e515d7a8e7f5c7a216fd54 100644 (file)
@@ -2496,16 +2496,6 @@ make_specified_string (const char *contents,
 }
 
 
-/* Make a string from the data at STR, treating it as multibyte if the
-   data warrants.  */
-
-Lisp_Object
-build_string (const char *str)
-{
-  return make_string (str, strlen (str));
-}
-
-
 /* Return an unibyte Lisp_String set up to hold LENGTH characters
    occupying LENGTH bytes.  */
 
index c5f7be3e7501ff9870d7af0914e36e751c373aac..cc0ddbb77e41d0f6c83b3e033b2c008456362620 100644 (file)
@@ -7570,7 +7570,7 @@ imagemagick_error (MagickWand *wand)
 
   description = MagickGetException (wand, &severity);
   image_error ("ImageMagick error: %s",
-              make_string (description, strlen (description)),
+              build_string (description),
               Qnil);
   description = (char *) MagickRelinquishMemory (description);
 }
index d6cc886bae3431a6e562d338546dcdb3ca0aa146..cac5370bd126dc8836f1e31decb374f3494e74ac 100644 (file)
@@ -2700,7 +2700,6 @@ EXFUN (Fmake_symbol, 1);
 EXFUN (Fmake_marker, 0);
 extern _Noreturn void string_overflow (void);
 EXFUN (Fmake_string, 2);
-extern Lisp_Object build_string (const char *);
 extern Lisp_Object make_string (const char *, ptrdiff_t);
 extern Lisp_Object make_unibyte_string (const char *, ptrdiff_t);
 extern Lisp_Object make_multibyte_string (const char *, ptrdiff_t, ptrdiff_t);
@@ -2713,6 +2712,16 @@ extern Lisp_Object make_specified_string (const char *,
 EXFUN (Fpurecopy, 1);
 extern Lisp_Object make_pure_string (const char *, ptrdiff_t, ptrdiff_t, int);
 extern Lisp_Object make_pure_c_string (const char *data);
+
+/* Make a string from the data at STR, treating it as multibyte if the
+   data warrants.  */
+
+static inline Lisp_Object
+build_string (const char *str)
+{
+  return make_string (str, strlen (str));
+}
+
 extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object);
 EXFUN (Fgarbage_collect, 0);
 extern void make_byte_code (struct Lisp_Vector *);
index 2f5f39e68b38ecf3ff1071c447897ba555744bec..3864d15623a5db8aab5a170fff99f7d46fcf1d4a 100644 (file)
@@ -777,7 +777,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
     }
 
   /* Handle executable names without an executable suffix.  */
-  program = make_string (cmdname, strlen (cmdname));
+  program = build_string (cmdname);
   if (NILP (Ffile_executable_p (program)))
     {
       struct gcpro gcpro1;
index f398e4dbb2056dcbf129651a64119d083767147d..be01513d910fef213ffc062c46351ac2659f61e9 100644 (file)
@@ -10036,7 +10036,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
           const char *file = "~/.emacs.d/gtkrc";
           Lisp_Object s, abs_file;
 
-          s = make_string (file, strlen (file));
+          s = build_string (file);
           abs_file = Fexpand_file_name (s, Qnil);
 
           if (! NILP (abs_file) && !NILP (Ffile_readable_p (abs_file)))