@@ -219,18 +219,15 @@ fn crossover_and_record_edges_details(
219219 tables : & mut tskit:: TableCollection ,
220220 rng : & mut StdRng ,
221221) {
222+ let mut pnodes = ( parent. node0 , parent. node1 ) ;
223+ mendel ( & mut pnodes, rng) ;
224+
222225 if params. xovers == 0.0 {
223- match tables. add_edge ( 0. , tables. sequence_length ( ) , parent . node0 , offspring_node) {
226+ match tables. add_edge ( 0. , tables. sequence_length ( ) , pnodes . 0 , offspring_node) {
224227 Ok ( _) => ( ) ,
225228 Err ( e) => panic ! ( "{}" , e) ,
226229 }
227230 } else {
228- let mut pnodes = ( parent. node0 , parent. node1 ) ;
229- mendel ( & mut pnodes, rng) ;
230-
231- let mut p0 = parent. node0 ;
232- let mut p1 = parent. node1 ;
233-
234231 let exp = match Exp :: new ( params. xovers / tables. sequence_length ( ) ) {
235232 Ok ( e) => e,
236233 Err ( e) => panic ! ( "{}" , e) ,
@@ -243,18 +240,22 @@ fn crossover_and_record_edges_details(
243240 match tables. add_edge (
244241 current_pos,
245242 current_pos + next_length,
246- p0 ,
243+ pnodes . 0 ,
247244 offspring_node,
248245 ) {
249246 Ok ( _) => ( ) ,
250247 Err ( e) => panic ! ( "{}" , e) ,
251248 }
252- std:: mem:: swap ( & mut p0 , & mut p1 ) ;
249+ std:: mem:: swap ( & mut pnodes . 0 , & mut pnodes . 1 ) ;
253250 current_pos += next_length;
254251 }
255252 Some ( _) => {
256- match tables. add_edge ( current_pos, tables. sequence_length ( ) , p0, offspring_node)
257- {
253+ match tables. add_edge (
254+ current_pos,
255+ tables. sequence_length ( ) ,
256+ pnodes. 0 ,
257+ offspring_node,
258+ ) {
258259 Ok ( _) => ( ) ,
259260 Err ( e) => panic ! ( "{}" , e) ,
260261 }
0 commit comments