From c1ee67038c87dcac8b7587890b63251f0c7a447c Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 25 Oct 2015 20:43:13 +0200 Subject: [PATCH] internally objects stop changing size --- lib/register/parfait_adapter.rb | 31 +------------------------------ test/parfait/test_object.rb | 5 ----- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/lib/register/parfait_adapter.rb b/lib/register/parfait_adapter.rb index f4f0a88a..48cae018 100644 --- a/lib/register/parfait_adapter.rb +++ b/lib/register/parfait_adapter.rb @@ -68,26 +68,11 @@ module Parfait include Positioned def fake_init - @memory = [0,nil] + @memory = Array.new(16) @position = nil self # for chaining end - # these internal functions are _really_ internal - # they respresent the smallest code needed to build larger functionality - # but should _never_ be used outside parfait. in fact that should be impossible - def internal_object_get_typeword - raise "failed init for #{self.class}" unless @memory - @memory[0] - end - def internal_object_set_typeword w - raise "failed init for #{self.class}" unless @memory - @memory[0] = w - end - def internal_object_length - raise "failed init for #{self.class}" unless @memory - @memory.length - 1 # take of type-word - end # 1 -based index def internal_object_get(index) @memory[index] @@ -98,20 +83,6 @@ module Parfait @memory[index] = value value end - def internal_object_grow(length) - old_length = internal_object_length() - while( old_length < length ) - internal_object_set( old_length + 1, nil) - old_length = old_length + 1 - end - end - def internal_object_shrink(length) - old_length = internal_object_length() - while( length < old_length ) - @memory.delete_at(old_length) - old_length = old_length - 1 - end - end end class List def to_sof_node(writer , level , ref ) diff --git a/test/parfait/test_object.rb b/test/parfait/test_object.rb index 1aa5c45b..cc30ef4e 100644 --- a/test/parfait/test_object.rb +++ b/test/parfait/test_object.rb @@ -10,11 +10,6 @@ class TestObject < MiniTest::Test assert_equal 1 , @object.internal_object_length end - def test_object_grow - @object.internal_object_grow( 2 ) - assert_equal 2 , @object.internal_object_length - end - def test_empty_object_doesnt_return assert_equal nil , @object.internal_object_get(3) end