only marking/counting occurences that are actually referenced, so numbers stay smaller
This commit is contained in:
parent
e13801c764
commit
9d5f62eded
@ -17,12 +17,12 @@ module Sof
|
||||
if( occurence = @objects[object] )
|
||||
#puts "reset level #{level} at #{occurence.level}"
|
||||
occurence.level = level if occurence.level > level
|
||||
occurence.referenced = true
|
||||
occurence.referenced = @counter
|
||||
@counter = @counter + 1
|
||||
return
|
||||
end
|
||||
o = Occurence.new( object , @counter , level )
|
||||
o = Occurence.new( object , level )
|
||||
@objects[object] = o
|
||||
@counter = @counter + 1
|
||||
attributes = attributes_for(object)
|
||||
attributes.each do |a|
|
||||
val = get_value( object , a)
|
||||
|
@ -1,12 +1,11 @@
|
||||
module Sof
|
||||
|
||||
class Occurence
|
||||
def initialize object , number , level
|
||||
def initialize object , level
|
||||
@object = object
|
||||
@number = number
|
||||
@level = level
|
||||
end
|
||||
attr_reader :object , :number
|
||||
attr_reader :object
|
||||
attr_accessor :level , :referenced
|
||||
end
|
||||
|
||||
|
@ -20,9 +20,9 @@ module Sof
|
||||
raise "no object #{object}" unless occurence
|
||||
if(level > occurence.level )
|
||||
#puts "level #{level} at #{occurence.level}"
|
||||
return SimpleNode.new("*#{occurence.number}")
|
||||
return SimpleNode.new("*#{occurence.referenced}")
|
||||
end
|
||||
ref = occurence.referenced ? occurence.number : nil
|
||||
ref = occurence.referenced
|
||||
if(object.respond_to? :to_sof_node) #mainly meant for arrays and hashes
|
||||
object.to_sof_node(self , level , ref )
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user