[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r109015: Avoid call to strlen in fast
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r109015: Avoid call to strlen in fast_c_string_match_ignore_case. |
Date: |
Wed, 11 Jul 2012 10:14:19 +0400 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 109015
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Wed 2012-07-11 10:14:19 +0400
message:
Avoid call to strlen in fast_c_string_match_ignore_case.
* search.c (fast_c_string_match_ignore_case): Change to use
length argument. Adjust users accordingly.
* lisp.h (fast_c_string_match_ignore_case): Adjust prototype.
modified:
src/ChangeLog
src/font.c
src/font.h
src/ftfont.c
src/lisp.h
src/lread.c
src/search.c
src/xfont.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-07-11 06:09:09 +0000
+++ b/src/ChangeLog 2012-07-11 06:14:19 +0000
@@ -1,3 +1,10 @@
+2012-07-11 Dmitry Antipov <address@hidden>
+
+ Avoid call to strlen in fast_c_string_match_ignore_case.
+ * search.c (fast_c_string_match_ignore_case): Change to use
+ length argument. Adjust users accordingly.
+ * lisp.h (fast_c_string_match_ignore_case): Adjust prototype.
+
2012-07-11 Paul Eggert <address@hidden>
Assume rename.
@@ -15,10 +22,12 @@
Avoid calls to strlen in font processing functions.
* font.c (font_parse_name, font_parse_xlfd, font_parse_fcname)
- (font_open_by_name): Changed to use length argument. Adjust
+ (font_open_by_name): Change to use length argument. Adjust
users accordingly.
- * font.h (font_open_by_name, font_parse_xlfd): Adjust prototypes.
- * xfont.c (xfont_decode_coding_xlfd): Changed to return ptrdiff_t.
+ * font.h (font_open_by_name, font_parse_xlfd, font_unparse_xlfd):
+ Adjust prototypes.
+ * xfont.c (xfont_decode_coding_xlfd, font_unparse_xlfd):
+ Change to return ptrdiff_t.
(xfont_list_pattern, xfont_match): Use length returned by
xfont_decode_coding_xlfd.
* xfns.c (x_default_font_parameter): Omit useless xstrdup.
@@ -107,7 +116,7 @@
Use XCAR and XCDR instead of Fcar and Fcdr where possible.
* callint.c, coding.c, doc.c, editfns.c, eval.c, font.c, fontset.c,
* frame.c, gnutls.c, minibuf.c, msdos.c, textprop.c, w32fns.c,
- * w32menu.c, window.c, xmenu.c: Changed to use XCAR and XCDR
+ * w32menu.c, window.c, xmenu.c: Change to use XCAR and XCDR
where argument type is known to be a Lisp_Cons.
2012-07-10 Tom Tromey <address@hidden>
=== modified file 'src/font.c'
--- a/src/font.c 2012-07-11 04:31:53 +0000
+++ b/src/font.c 2012-07-11 06:14:19 +0000
@@ -1199,7 +1199,7 @@
length), and return the name length. If FONT_SIZE_INDEX of FONT is
0, use PIXEL_SIZE instead. */
-int
+ptrdiff_t
font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes)
{
char *p;
@@ -2642,15 +2642,18 @@
if (! NILP (Vface_ignored_fonts))
{
char name[256];
+ ptrdiff_t namelen;
Lisp_Object tail, regexp;
- if (font_unparse_xlfd (entity, 0, name, 256) >= 0)
+ namelen = font_unparse_xlfd (entity, 0, name, 256);
+ if (namelen >= 0)
{
for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail))
{
regexp = XCAR (tail);
if (STRINGP (regexp)
- && fast_c_string_match_ignore_case (regexp, name) >= 0)
+ && fast_c_string_match_ignore_case (regexp, name,
+ namelen) >= 0)
break;
}
if (CONSP (tail))
=== modified file 'src/font.h'
--- a/src/font.h 2012-07-11 04:31:53 +0000
+++ b/src/font.h 2012-07-11 06:14:19 +0000
@@ -782,8 +782,8 @@
Lisp_Object spec);
extern int font_parse_xlfd (char *name, ptrdiff_t len, Lisp_Object font);
-extern int font_unparse_xlfd (Lisp_Object font, int pixel_size,
- char *name, int bytes);
+extern ptrdiff_t font_unparse_xlfd (Lisp_Object font, int pixel_size,
+ char *name, int bytes);
extern int font_unparse_fcname (Lisp_Object font, int pixel_size,
char *name, int bytes);
extern void register_font_driver (struct font_driver *driver, FRAME_PTR f);
=== modified file 'src/ftfont.c'
--- a/src/ftfont.c 2012-07-05 18:35:48 +0000
+++ b/src/ftfont.c 2012-07-11 06:14:19 +0000
@@ -598,7 +598,9 @@
re[j] = '\0';
regexp = make_unibyte_string (re, j);
for (i = 0; fc_charset_table[i].name; i++)
- if (fast_c_string_match_ignore_case (regexp, fc_charset_table[i].name) >=
0)
+ if (fast_c_string_match_ignore_case
+ (regexp, fc_charset_table[i].name,
+ strlen (fc_charset_table[i].name)) >= 0)
break;
if (! fc_charset_table[i].name)
return -1;
=== modified file 'src/lisp.h'
--- a/src/lisp.h 2012-07-10 08:43:46 +0000
+++ b/src/lisp.h 2012-07-11 06:14:19 +0000
@@ -2896,7 +2896,8 @@
struct re_registers *,
Lisp_Object, int, int);
extern ptrdiff_t fast_string_match (Lisp_Object, Lisp_Object);
-extern ptrdiff_t fast_c_string_match_ignore_case (Lisp_Object, const char *);
+extern ptrdiff_t fast_c_string_match_ignore_case (Lisp_Object, const char *,
+ ptrdiff_t);
extern ptrdiff_t fast_string_match_ignore_case (Lisp_Object, Lisp_Object);
extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t,
ptrdiff_t, ptrdiff_t, Lisp_Object);
=== modified file 'src/lread.c'
--- a/src/lread.c 2012-07-10 23:24:36 +0000
+++ b/src/lread.c 2012-07-11 06:14:19 +0000
@@ -906,7 +906,7 @@
if (i >= nbytes
|| fast_c_string_match_ignore_case (Vbytecomp_version_regexp,
- buf + i) < 0)
+ buf + i, nbytes - i) < 0)
safe_p = 0;
}
if (safe_p)
=== modified file 'src/search.c'
--- a/src/search.c 2012-07-10 08:43:46 +0000
+++ b/src/search.c 2012-07-11 06:14:19 +0000
@@ -490,11 +490,11 @@
We assume that STRING contains single-byte characters. */
ptrdiff_t
-fast_c_string_match_ignore_case (Lisp_Object regexp, const char *string)
+fast_c_string_match_ignore_case (Lisp_Object regexp,
+ const char *string, ptrdiff_t len)
{
ptrdiff_t val;
struct re_pattern_buffer *bufp;
- size_t len = strlen (string);
regexp = string_make_unibyte (regexp);
re_match_object = Qt;
=== modified file 'src/xfont.c'
--- a/src/xfont.c 2012-07-11 04:31:53 +0000
+++ b/src/xfont.c 2012-07-11 06:14:19 +0000
@@ -434,7 +434,8 @@
{
elt = XCAR (tail);
if (STRINGP (elt)
- && fast_c_string_match_ignore_case (elt, indices[i]) >= 0)
+ && fast_c_string_match_ignore_case (elt, indices[i],
+ len) >= 0)
break;
}
if (! CONSP (tail))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r109015: Avoid call to strlen in fast_c_string_match_ignore_case.,
Dmitry Antipov <=