diff options
| author | Dmitry Antipov | 2012-06-26 09:00:30 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-06-26 09:00:30 +0400 |
| commit | 1130ecfcacce9743078221b956cd07b352776442 (patch) | |
| tree | 4e2e38f1d5ea6cabc022cdca485d0d3ee92c91ef /src | |
| parent | 99027bdd81f63ea690394a153ef49a08f55e498d (diff) | |
| download | emacs-1130ecfcacce9743078221b956cd07b352776442.tar.gz emacs-1130ecfcacce9743078221b956cd07b352776442.zip | |
* src/alloc.c: Remove build_string.
* 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/alloc.c | 10 | ||||
| -rw-r--r-- | src/image.c | 2 | ||||
| -rw-r--r-- | src/lisp.h | 11 | ||||
| -rw-r--r-- | src/w32proc.c | 2 | ||||
| -rw-r--r-- | src/xterm.c | 2 |
6 files changed, 23 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5b3387b8134..ff3fa02790e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2012-06-26 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | * alloc.c: Remove build_string. | ||
| 4 | * lisp.h: Define build_string as static inline. This provides | ||
| 5 | a better opportunity to optimize away calls to strlen when the | ||
| 6 | function is called with compile-time constant argument. | ||
| 7 | * image.c (imagemagick_error): Convert to build_string. | ||
| 8 | * w32proc.c (sys_spawnve): Likewise. | ||
| 9 | * xterm.c (x_term_init): Likewise. | ||
| 10 | |||
| 1 | 2012-06-26 Paul Eggert <eggert@cs.ucla.edu> | 11 | 2012-06-26 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 12 | ||
| 3 | Use sprintf return value instead of invoking strlen on result. | 13 | Use sprintf return value instead of invoking strlen on result. |
diff --git a/src/alloc.c b/src/alloc.c index 490632f282f..6f7cc968b81 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -2496,16 +2496,6 @@ make_specified_string (const char *contents, | |||
| 2496 | } | 2496 | } |
| 2497 | 2497 | ||
| 2498 | 2498 | ||
| 2499 | /* Make a string from the data at STR, treating it as multibyte if the | ||
| 2500 | data warrants. */ | ||
| 2501 | |||
| 2502 | Lisp_Object | ||
| 2503 | build_string (const char *str) | ||
| 2504 | { | ||
| 2505 | return make_string (str, strlen (str)); | ||
| 2506 | } | ||
| 2507 | |||
| 2508 | |||
| 2509 | /* Return an unibyte Lisp_String set up to hold LENGTH characters | 2499 | /* Return an unibyte Lisp_String set up to hold LENGTH characters |
| 2510 | occupying LENGTH bytes. */ | 2500 | occupying LENGTH bytes. */ |
| 2511 | 2501 | ||
diff --git a/src/image.c b/src/image.c index c5f7be3e750..cc0ddbb77e4 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -7570,7 +7570,7 @@ imagemagick_error (MagickWand *wand) | |||
| 7570 | 7570 | ||
| 7571 | description = MagickGetException (wand, &severity); | 7571 | description = MagickGetException (wand, &severity); |
| 7572 | image_error ("ImageMagick error: %s", | 7572 | image_error ("ImageMagick error: %s", |
| 7573 | make_string (description, strlen (description)), | 7573 | build_string (description), |
| 7574 | Qnil); | 7574 | Qnil); |
| 7575 | description = (char *) MagickRelinquishMemory (description); | 7575 | description = (char *) MagickRelinquishMemory (description); |
| 7576 | } | 7576 | } |
diff --git a/src/lisp.h b/src/lisp.h index d6cc886bae3..cac5370bd12 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2700,7 +2700,6 @@ EXFUN (Fmake_symbol, 1); | |||
| 2700 | EXFUN (Fmake_marker, 0); | 2700 | EXFUN (Fmake_marker, 0); |
| 2701 | extern _Noreturn void string_overflow (void); | 2701 | extern _Noreturn void string_overflow (void); |
| 2702 | EXFUN (Fmake_string, 2); | 2702 | EXFUN (Fmake_string, 2); |
| 2703 | extern Lisp_Object build_string (const char *); | ||
| 2704 | extern Lisp_Object make_string (const char *, ptrdiff_t); | 2703 | extern Lisp_Object make_string (const char *, ptrdiff_t); |
| 2705 | extern Lisp_Object make_unibyte_string (const char *, ptrdiff_t); | 2704 | extern Lisp_Object make_unibyte_string (const char *, ptrdiff_t); |
| 2706 | extern Lisp_Object make_multibyte_string (const char *, ptrdiff_t, ptrdiff_t); | 2705 | extern Lisp_Object make_multibyte_string (const char *, ptrdiff_t, ptrdiff_t); |
| @@ -2713,6 +2712,16 @@ extern Lisp_Object make_specified_string (const char *, | |||
| 2713 | EXFUN (Fpurecopy, 1); | 2712 | EXFUN (Fpurecopy, 1); |
| 2714 | extern Lisp_Object make_pure_string (const char *, ptrdiff_t, ptrdiff_t, int); | 2713 | extern Lisp_Object make_pure_string (const char *, ptrdiff_t, ptrdiff_t, int); |
| 2715 | extern Lisp_Object make_pure_c_string (const char *data); | 2714 | extern Lisp_Object make_pure_c_string (const char *data); |
| 2715 | |||
| 2716 | /* Make a string from the data at STR, treating it as multibyte if the | ||
| 2717 | data warrants. */ | ||
| 2718 | |||
| 2719 | static inline Lisp_Object | ||
| 2720 | build_string (const char *str) | ||
| 2721 | { | ||
| 2722 | return make_string (str, strlen (str)); | ||
| 2723 | } | ||
| 2724 | |||
| 2716 | extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object); | 2725 | extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object); |
| 2717 | EXFUN (Fgarbage_collect, 0); | 2726 | EXFUN (Fgarbage_collect, 0); |
| 2718 | extern void make_byte_code (struct Lisp_Vector *); | 2727 | extern void make_byte_code (struct Lisp_Vector *); |
diff --git a/src/w32proc.c b/src/w32proc.c index 2f5f39e68b3..3864d15623a 100644 --- a/src/w32proc.c +++ b/src/w32proc.c | |||
| @@ -777,7 +777,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) | |||
| 777 | } | 777 | } |
| 778 | 778 | ||
| 779 | /* Handle executable names without an executable suffix. */ | 779 | /* Handle executable names without an executable suffix. */ |
| 780 | program = make_string (cmdname, strlen (cmdname)); | 780 | program = build_string (cmdname); |
| 781 | if (NILP (Ffile_executable_p (program))) | 781 | if (NILP (Ffile_executable_p (program))) |
| 782 | { | 782 | { |
| 783 | struct gcpro gcpro1; | 783 | struct gcpro gcpro1; |
diff --git a/src/xterm.c b/src/xterm.c index f398e4dbb20..be01513d910 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -10036,7 +10036,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10036 | const char *file = "~/.emacs.d/gtkrc"; | 10036 | const char *file = "~/.emacs.d/gtkrc"; |
| 10037 | Lisp_Object s, abs_file; | 10037 | Lisp_Object s, abs_file; |
| 10038 | 10038 | ||
| 10039 | s = make_string (file, strlen (file)); | 10039 | s = build_string (file); |
| 10040 | abs_file = Fexpand_file_name (s, Qnil); | 10040 | abs_file = Fexpand_file_name (s, Qnil); |
| 10041 | 10041 | ||
| 10042 | if (! NILP (abs_file) && !NILP (Ffile_readable_p (abs_file))) | 10042 | if (! NILP (abs_file) && !NILP (Ffile_readable_p (abs_file))) |