summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-13 02:12:40 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-13 02:12:40 +0000
commitc5b19cf01cd15e0d9d8e2847ba746a5f361841df (patch)
tree1c7e44cbc22b88e90df137a0fc52a454d1c3ebdc /re.c
parentd24e2d746f417a041499e66cc54bafdf221f00ad (diff)
* 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
Diffstat (limited to 're.c')
-rw-r--r--re.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/re.c b/re.c
index ea11f1c015..97803d4e38 100644
--- a/re.c
+++ b/re.c
@@ -97,6 +97,18 @@ rb_memcmp(const void *p1, const void *p2, long 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
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;
}
+#endif
static inline long
rb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n)