* string.c (rb_str_times): reduce loop overhead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-02-17 00:18:16 +00:00
parent 71c5e48598
commit 35cb0f807b
3 changed files with 23 additions and 5 deletions

View file

@ -174,7 +174,7 @@ class TestString < Test::Unit::TestCase
s = "a"
10.times {|i|
s << s
assert_equal("a" * (2<<i), s)
assert_equal("a" * (2 << i), s)
}
end
@ -1370,4 +1370,13 @@ class TestString < Test::Unit::TestCase
def test_end_with?
assert("abc".end_with?("c"))
end
def test_times
s1 = ''
100.times {|n|
s2 = "a" * n
assert_equal(s1, s2)
s1 << 'a'
}
end
end