* re.c (rb_memsearch_ss): performance improvement by using memmem(3) if
possible. [ruby-dev:45530] [Feature #6311] * configure.in: check existence of memmem(3) and that it is not broken. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d24e2d746f
commit
c5b19cf01c
@ -1,3 +1,10 @@
|
|||||||
|
Tue Nov 13 11:03:47 2012 Masaki Matsushita <glass.saga@gmail.com>
|
||||||
|
|
||||||
|
* re.c (rb_memsearch_ss): performance improvement by using memmem(3) if
|
||||||
|
possible. [ruby-dev:45530] [Feature #6311]
|
||||||
|
|
||||||
|
* configure.in: check existence of memmem(3) and that it is not broken.
|
||||||
|
|
||||||
Tue Nov 13 06:50:02 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
Tue Nov 13 06:50:02 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
* probes.d: add DTrace probe declarations. [ruby-core:27448]
|
* probes.d: add DTrace probe declarations. [ruby-core:27448]
|
||||||
|
36
configure.in
36
configure.in
@ -2900,6 +2900,42 @@ if test "${universal_binary-no}" = yes ; then
|
|||||||
])])
|
])])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AC_CHECK_FUNC(memmem, [
|
||||||
|
AC_CACHE_CHECK(for broken memmem, rb_cv_broken_memmem, [
|
||||||
|
AC_TRY_RUN([
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
char *str = "hogefugafoobar";
|
||||||
|
char *rs = "foo";
|
||||||
|
char *empty = "";
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
p = memmem(str, strlen(str), rs, strlen(rs));
|
||||||
|
if (p == str+8) {
|
||||||
|
p = memmem(str, strlen(str), empty, strlen(empty));
|
||||||
|
if (p == str)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
rb_cv_broken_memmem=no,
|
||||||
|
rb_cv_broken_memmem=yes,
|
||||||
|
rb_cv_broken_memmem=yes)
|
||||||
|
])
|
||||||
|
if test "$rb_cv_broken_memmem" = no; then
|
||||||
|
AC_DEFINE(HAVE_MEMMEM, 1)
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
CPPFLAGS="$CPPFLAGS "'$(DEFS)'
|
CPPFLAGS="$CPPFLAGS "'$(DEFS)'
|
||||||
test -z "$CPPFLAGS" || CPPFLAGS="$CPPFLAGS "; CPPFLAGS="$CPPFLAGS"'${cppflags}'
|
test -z "$CPPFLAGS" || CPPFLAGS="$CPPFLAGS "; CPPFLAGS="$CPPFLAGS"'${cppflags}'
|
||||||
if test -n "${cflags+set}"; then
|
if test -n "${cflags+set}"; then
|
||||||
|
13
re.c
13
re.c
@ -97,6 +97,18 @@ rb_memcmp(const void *p1, const void *p2, long len)
|
|||||||
return memcmp(p1, p2, len);
|
return memcmp(p1, p2, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_MEMMEM
|
||||||
|
static inline long
|
||||||
|
rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
|
||||||
|
{
|
||||||
|
const unsigned char *y;
|
||||||
|
|
||||||
|
if (y = memmem(ys, n, xs, m))
|
||||||
|
return y - ys;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
static inline long
|
static inline long
|
||||||
rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
|
rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
|
||||||
{
|
{
|
||||||
@ -132,6 +144,7 @@ rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n
|
|||||||
}
|
}
|
||||||
return y - ys - m;
|
return y - ys - m;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline long
|
static inline long
|
||||||
rb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n)
|
rb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user