File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -138,18 +138,23 @@ fn finalize(self: *Trie, allocator: Allocator) !void {
138138 defer ordered_nodes .deinit ();
139139 try ordered_nodes .ensureTotalCapacityPrecise (self .nodes .items (.is_terminal ).len );
140140
141- var fifo = std .fifo .LinearFifo (Node .Index , .Dynamic ).init (allocator );
142- defer fifo .deinit ();
143-
144- try fifo .writeItem (self .root .? );
145-
146- while (fifo .readItem ()) | next_index | {
147- const edges = & self .nodes .items (.edges )[next_index ];
148- for (edges .items ) | edge_index | {
149- const edge = self .edges .items [edge_index ];
150- try fifo .writeItem (edge .node );
141+ {
142+ var fifo : std .ArrayListUnmanaged (Node .Index ) = .empty ;
143+ defer fifo .deinit (allocator );
144+
145+ try fifo .append (allocator , self .root .? );
146+
147+ var i : usize = 0 ;
148+ while (i < fifo .items .len ) {
149+ const next_index = fifo .items [i ];
150+ i += 1 ;
151+ const edges = & self .nodes .items (.edges )[next_index ];
152+ for (edges .items ) | edge_index | {
153+ const edge = self .edges .items [edge_index ];
154+ try fifo .append (allocator , edge .node );
155+ }
156+ ordered_nodes .appendAssumeCapacity (next_index );
151157 }
152- ordered_nodes .appendAssumeCapacity (next_index );
153158 }
154159
155160 var more : bool = true ;
You can’t perform that action at this time.
0 commit comments