From 61e21e82adadc1795de115a9ebe0019245de007d Mon Sep 17 00:00:00 2001 From: knu Date: Thu, 22 Nov 2012 05:23:12 +0000 Subject: Apply performance improvement to short byte array search. * re.c (rb_memsearch_ss): Apply performance improvement to short byte array search for platforms without memmem(3). [Feature #6311] [ruby-dev:45530] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- re.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 're.c') diff --git a/re.c b/re.c index 97803d4e38..8fa1abc0e6 100644 --- a/re.c +++ b/re.c @@ -126,6 +126,9 @@ rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n if (m > SIZEOF_VALUE) rb_bug("!!too long pattern string!!"); + if (!(y = memchr(y, *x, n - m + 1))) + return -1; + /* Prepare hash value */ for (hx = *x++, hy = *y++; x < xe; ++x, ++y) { hx <<= CHAR_BIT; -- cgit v1.2.3