diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-03 02:27:50 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-03 02:27:50 +0000 |
commit | 574422733dd11b242ba04c02579710e42fa58a77 (patch) | |
tree | a9c92e59c4b7b8b730f1e789b59e98a173fd1b5d /test/ruby | |
parent | a84bfcbf0061d30946e4d9692e9d4fa70682aef4 (diff) | |
download | ruby-574422733dd11b242ba04c02579710e42fa58a77.tar.gz |
* array.c: Improve performance of Array#shift. use shared instead of
MEMMOVE if with arguments. Patch by @ksss [fix GH-537]
* test/ruby/test_array.rb: ditto.
* benchmark/bm_array_shift.rb: Added benchmark of GH-537 issue.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_array.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 0a4b1379f1..04e66cce11 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1904,6 +1904,8 @@ class TestArray < Test::Unit::TestCase a[3] = 3 a.shift(2) assert_equal([2, 3], a) + + assert_equal([1,1,1], ([1] * 100).shift(3)) end def test_unshift_error @@ -2356,6 +2358,11 @@ class TestArray < Test::Unit::TestCase b.replace(a) assert_equal((1..10).to_a, a.shift(10)) assert_equal((11..100).to_a, a) + + a = (1..30).to_a + assert_equal((1..3).to_a, a.shift(3)) + # occupied + assert_equal((4..6).to_a, a.shift(3)) end def test_replace_shared_ary |