summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-08 13:40:33 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-08 13:40:33 +0000
commit9f9ebe4ebae2769be512e46e720c3e523b7f7479 (patch)
treec3282f29886aed0361a992bcaa11985d67b86108 /re.c
parent6ce8c33936d59716a0676d2ec8e22b22e2a1da94 (diff)
* re.c (rb_memsearch): performance improvement by using memchr().
[ruby-dev:45397] [Feature #6173] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/re.c b/re.c
index 70e3c3fe34..ea11f1c015 100644
--- a/re.c
+++ b/re.c
@@ -220,12 +220,12 @@ rb_memsearch(const void *x0, long m, const void *y0, long n, rb_encoding *enc)
return 0;
}
else if (m == 1) {
- const unsigned char *ys = y, *ye = ys + n;
- for (; y < ye; ++y) {
- if (*x == *y)
- return y - ys;
- }
- return -1;
+ const unsigned char *ys;
+
+ if (ys = memchr(y, *x, n))
+ return ys - y;
+ else
+ return -1;
}
else if (m <= SIZEOF_VALUE) {
return rb_memsearch_ss(x0, m, y0, n);