ruby-changes:23811
From: drbrain <ko1@a...>
Date: Sat, 2 Jun 2012 07:06:18 +0900 (JST)
Subject: [ruby-changes:23811] drbrain:r35862 (trunk): * doc/re.rdoc (Performance): Replaced incorrect example of reducing
drbrain 2012-06-02 07:05:46 +0900 (Sat, 02 Jun 2012) New Revision: 35862 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35862 Log: * doc/re.rdoc (Performance): Replaced incorrect example of reducing backtracking through anchoring with reduced backtracking through a range. [ruby-trunk - Bug #6525] Modified files: trunk/ChangeLog trunk/doc/re.rdoc Index: doc/re.rdoc =================================================================== --- doc/re.rdoc (revision 35861) +++ doc/re.rdoc (revision 35862) @@ -640,9 +640,10 @@ while still matching the mandatory 29. It is plain to us that none of the optional matches can succeed, but this fact unfortunately eludes Ruby. -One approach for improving performance is to anchor the match to the -beginning of the string, thus significantly reducing the amount of -backtracking needed. +The best way to improve performance is to significantly reduce the amount of +backtracking needed. For this case, instead of individually matching 29 +optional <i>a</i>s, a range of optional <i>a</i>s can be matched all at once +with <i>a{0,29}</i>: - Regexp.new('\A' 'a?' * 29 + 'a' * 29) =~ 'a' * 29 + Regexp.new('a{0,29}' + 'a' * 29) =~ 'a' * 29 Index: ChangeLog =================================================================== --- ChangeLog (revision 35861) +++ ChangeLog (revision 35862) @@ -1,3 +1,9 @@ +Sat Jun 2 07:04:48 2012 Eric Hodel <drbrain@s...> + + * doc/re.rdoc (Performance): Replaced incorrect example of reducing + backtracking through anchoring with reduced backtracking through a + range. [ruby-trunk - Bug #6525] + Sat Jun 2 06:34:15 2012 Eric Hodel <drbrain@s...> * doc/re.rdoc (Performance): Removed useless sample output from final -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/