@@ -219,18 +219,15 @@ fn crossover_and_record_edges_details(
219
219
tables : & mut tskit:: TableCollection ,
220
220
rng : & mut StdRng ,
221
221
) {
222
+ let mut pnodes = ( parent. node0 , parent. node1 ) ;
223
+ mendel ( & mut pnodes, rng) ;
224
+
222
225
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) {
224
227
Ok ( _) => ( ) ,
225
228
Err ( e) => panic ! ( "{}" , e) ,
226
229
}
227
230
} 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
-
234
231
let exp = match Exp :: new ( params. xovers / tables. sequence_length ( ) ) {
235
232
Ok ( e) => e,
236
233
Err ( e) => panic ! ( "{}" , e) ,
@@ -243,18 +240,22 @@ fn crossover_and_record_edges_details(
243
240
match tables. add_edge (
244
241
current_pos,
245
242
current_pos + next_length,
246
- p0 ,
243
+ pnodes . 0 ,
247
244
offspring_node,
248
245
) {
249
246
Ok ( _) => ( ) ,
250
247
Err ( e) => panic ! ( "{}" , e) ,
251
248
}
252
- std:: mem:: swap ( & mut p0 , & mut p1 ) ;
249
+ std:: mem:: swap ( & mut pnodes . 0 , & mut pnodes . 1 ) ;
253
250
current_pos += next_length;
254
251
}
255
252
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
+ ) {
258
259
Ok ( _) => ( ) ,
259
260
Err ( e) => panic ! ( "{}" , e) ,
260
261
}
0 commit comments