ruby-changes:25507
From: glass <ko1@a...>
Date: Thu, 8 Nov 2012 22:40:44 +0900 (JST)
Subject: [ruby-changes:25507] glass:r37564 (trunk): * re.c (rb_memsearch): performance improvement by using memchr().
glass 2012-11-08 22:40:33 +0900 (Thu, 08 Nov 2012) New Revision: 37564 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37564 Log: * re.c (rb_memsearch): performance improvement by using memchr(). [ruby-dev:45397] [Feature #6173] Modified files: trunk/ChangeLog trunk/re.c Index: ChangeLog =================================================================== --- ChangeLog (revision 37563) +++ ChangeLog (revision 37564) @@ -1,3 +1,8 @@ +Thu Nov 8 21:57:59 2012 Masaki Matsushita <glass.saga@g...> + + * re.c (rb_memsearch): performance improvement by using memchr(). + [ruby-dev:45397] [Feature #6173] + Thu Nov 8 19:02:50 2012 NARUSE, Yui <naruse@r...> * lib/net/protocol.rb (Net::InternetMessageIO#each_crlf_line): Index: re.c =================================================================== --- re.c (revision 37563) +++ re.c (revision 37564) @@ -220,12 +220,12 @@ 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/