Skip to content

Commit

Permalink
* re.c (rb_memsearch): performance improvement by using memchr().
Browse files Browse the repository at this point in the history
  [ruby-dev:45397] [Feature ruby#6173]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
glass committed Nov 8, 2012
1 parent 6ce8c33 commit 9f9ebe4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Thu Nov 8 21:57:59 2012 Masaki Matsushita <[email protected]>

* re.c (rb_memsearch): performance improvement by using memchr().
[ruby-dev:45397] [Feature #6173]

Thu Nov 8 19:02:50 2012 NARUSE, Yui <[email protected]>

* lib/net/protocol.rb (Net::InternetMessageIO#each_crlf_line):
Expand Down
12 changes: 6 additions & 6 deletions re.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9f9ebe4

Please sign in to comment.