internally objects stop changing size

This commit is contained in:
Torsten Ruger 2015-10-25 20:43:13 +02:00
parent 92fe12a0d1
commit c1ee67038c
2 changed files with 1 additions and 35 deletions

View File

@ -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 )

View File

@ -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