diff options
| author | Dmitry Antipov | 2012-07-10 11:59:31 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-10 11:59:31 +0400 |
| commit | cb1caeaf2ba26df05e8f9bcd4aa63203cef781fb (patch) | |
| tree | 78cbdfcc89455a0ab097eb1fd16c029d0ac48e0d /src/font.c | |
| parent | d02eb359e68a083fc55f0355b86df2a07b8d570d (diff) | |
| download | emacs-cb1caeaf2ba26df05e8f9bcd4aa63203cef781fb.tar.gz emacs-cb1caeaf2ba26df05e8f9bcd4aa63203cef781fb.zip | |
Avoid calls to strlen in miscellaneous functions.
* buffer.c (init_buffer): Use precalculated len, adjust if needed.
* font.c (Ffont_xlfd_name): Likewise. Change to call make_string.
* lread.c (openp): Likewise.
Diffstat (limited to 'src/font.c')
| -rw-r--r-- | src/font.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/font.c b/src/font.c index 4f0f814a583..1eca1c2eb29 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -4218,7 +4218,7 @@ the consecutive wildcards are folded into one. */) | |||
| 4218 | (Lisp_Object font, Lisp_Object fold_wildcards) | 4218 | (Lisp_Object font, Lisp_Object fold_wildcards) |
| 4219 | { | 4219 | { |
| 4220 | char name[256]; | 4220 | char name[256]; |
| 4221 | int pixel_size = 0; | 4221 | int namelen, pixel_size = 0; |
| 4222 | 4222 | ||
| 4223 | CHECK_FONT (font); | 4223 | CHECK_FONT (font); |
| 4224 | 4224 | ||
| @@ -4232,11 +4232,13 @@ the consecutive wildcards are folded into one. */) | |||
| 4232 | if (NILP (fold_wildcards)) | 4232 | if (NILP (fold_wildcards)) |
| 4233 | return font_name; | 4233 | return font_name; |
| 4234 | strcpy (name, SSDATA (font_name)); | 4234 | strcpy (name, SSDATA (font_name)); |
| 4235 | namelen = SBYTES (font_name); | ||
| 4235 | goto done; | 4236 | goto done; |
| 4236 | } | 4237 | } |
| 4237 | pixel_size = XFONT_OBJECT (font)->pixel_size; | 4238 | pixel_size = XFONT_OBJECT (font)->pixel_size; |
| 4238 | } | 4239 | } |
| 4239 | if (font_unparse_xlfd (font, pixel_size, name, 256) < 0) | 4240 | namelen = font_unparse_xlfd (font, pixel_size, name, 256); |
| 4241 | if (namelen < 0) | ||
| 4240 | return Qnil; | 4242 | return Qnil; |
| 4241 | done: | 4243 | done: |
| 4242 | if (! NILP (fold_wildcards)) | 4244 | if (! NILP (fold_wildcards)) |
| @@ -4246,11 +4248,12 @@ the consecutive wildcards are folded into one. */) | |||
| 4246 | while ((p1 = strstr (p0, "-*-*"))) | 4248 | while ((p1 = strstr (p0, "-*-*"))) |
| 4247 | { | 4249 | { |
| 4248 | strcpy (p1, p1 + 2); | 4250 | strcpy (p1, p1 + 2); |
| 4251 | namelen -= 2; | ||
| 4249 | p0 = p1; | 4252 | p0 = p1; |
| 4250 | } | 4253 | } |
| 4251 | } | 4254 | } |
| 4252 | 4255 | ||
| 4253 | return build_string (name); | 4256 | return make_string (name, namelen); |
| 4254 | } | 4257 | } |
| 4255 | 4258 | ||
| 4256 | DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0, | 4259 | DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0, |