From 457c2c4a55b5896b30510ff8b39256b61b46cdf4 Mon Sep 17 00:00:00 2001 From: mame Date: Wed, 17 Feb 2010 12:36:41 +0000 Subject: * regcomp.c (setup_tree, onig_compile): optimize .* at last by converting into (?>.*), which does not backtrack. [ruby-core:27791] * test/ruby/test_regexp.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_regexp.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 4cd35d5248..06c6d1c633 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -800,4 +800,11 @@ class TestRegexp < Test::Unit::TestCase assert_nothing_raised { eval("a = 1; /\#{ a }/; a") } assert_nothing_raised { eval("a = 1; /\#{ a }/o; a") } end + + def test_optimize_last_anycharstar + s = "1" + " " * 5000000 + assert_nothing_raised { s.match(/(\d) (.*)/) } + assert_equal("1", $1) + assert_equal(" " * 4999999, $2) + end end -- cgit v1.2.3