##// END OF EJS Templates
rust-index: remove one collect when converting back...
Raphaël Gomès -
r52319:3099f1c6 default
parent child Browse files
Show More
@@ -989,20 +989,15 b' impl Index {'
989 // Ugly hack, but temporary
989 // Ugly hack, but temporary
990 const IDX_TO_PHASE_NUM: [usize; 4] = [1, 2, 32, 96];
990 const IDX_TO_PHASE_NUM: [usize; 4] = [1, 2, 32, 96];
991 let py_phase_maps = PyDict::new(py);
991 let py_phase_maps = PyDict::new(py);
992 for (idx, roots) in phase_maps.iter().enumerate() {
992 for (idx, roots) in phase_maps.into_iter().enumerate() {
993 let phase_num = IDX_TO_PHASE_NUM[idx].into_py_object(py);
993 let phase_num = IDX_TO_PHASE_NUM[idx].into_py_object(py);
994 // OPTIM too bad we have to collect here. At least, we could
994 // This is a bit faster than collecting into a `Vec` and passing
995 // reuse the same Vec and allocate it with capacity at
995 // it to `PySet::new`.
996 // max(len(phase_maps)
996 let set = PySet::empty(py)?;
997 let roots_vec: Vec<PyInt> = roots
997 for rev in roots {
998 .iter()
998 set.add(py, PyRevision::from(rev).into_py_object(py))?;
999 .map(|r| PyRevision::from(*r).into_py_object(py))
999 }
1000 .collect();
1000 py_phase_maps.set_item(py, phase_num, set)?;
1001 py_phase_maps.set_item(
1002 py,
1003 phase_num,
1004 PySet::new(py, roots_vec)?,
1005 )?;
1006 }
1001 }
1007 Ok(PyTuple::new(
1002 Ok(PyTuple::new(
1008 py,
1003 py,
General Comments 0
You need to be logged in to leave comments. Login now