Skip to content

Commit

Permalink
Optimize calculating predecessors
Browse files Browse the repository at this point in the history
  • Loading branch information
junk0612 committed Oct 25, 2024
1 parent 0ba3241 commit bc4010a
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions lib/lrama/states.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def compute
end

def compute_ielr
report_duration(:compute_predecessors) { compute_predecessors }
report_duration(:split_states) { split_states }
report_duration(:compute_direct_read_sets) { compute_direct_read_sets }
report_duration(:compute_reads_relation) { compute_reads_relation }
Expand Down Expand Up @@ -280,7 +279,10 @@ def compute_lr0_states
state.shifts.each do |shift|
new_state, created = create_state(shift.next_sym, shift.next_items, states_created)
state.set_items_to_state(shift.next_items, new_state)
enqueue_state(states, new_state) if created
if created
enqueue_state(states, new_state)
new_state.append_predecessor(state)
end
end
end
end
Expand Down Expand Up @@ -540,17 +542,6 @@ def compute_default_reduction
end
end

def compute_predecessors
queue = [@states.first]
until queue.empty?
state = queue.shift
state.transitions.each do |_, next_state|
next_state.append_predecessor(state)
queue << next_state
end
end
end

def split_states
transition_queue = []
@states.each do |state|
Expand Down

0 comments on commit bc4010a

Please sign in to comment.