mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
6ce8c33936
commit
9f9ebe4eba
2 changed files with 11 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
|||
Thu Nov 8 21:57:59 2012 Masaki Matsushita <glass.saga@gmail.com>
|
||||
|
||||
* re.c (rb_memsearch): performance improvement by using memchr().
|
||||
[ruby-dev:45397] [Feature #6173]
|
||||
|
||||
Thu Nov 8 19:02:50 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* lib/net/protocol.rb (Net::InternetMessageIO#each_crlf_line):
|
||||
|
|
12
re.c
12
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);
|
||||
|
|
Loading…
Reference in a new issue