rust-pyo3-revlog: _index_ancestors
This one was really straightforward.
Looking at the (also quite simple) rust-cpython version, I am now
convinced that we do have one less copy, because of this:
PyList::new(py, &as_vec)
Namely, in rust-cpython, `PyList::new` does not take ownership of
the incoming vector, hence it must copy it, and that makes copying
twice with the previous collection in `as_vec`.
--- a/rust/hg-pyo3/src/revlog/mod.rs Mon Dec 23 20:44:26 2024 +0100
+++ b/rust/hg-pyo3/src/revlog/mod.rs Mon Dec 23 21:03:38 2024 +0100
@@ -367,6 +367,26 @@
})
}
+ /// return the gca set of the given revs
+ #[pyo3(signature = (*revs))]
+ fn _index_ancestors(
+ slf: &Bound<'_, Self>,
+ revs: &Bound<'_, PyTuple>,
+ ) -> PyResult<PyObject> {
+ Self::with_index_read(slf, |idx| {
+ let revs: Vec<_> = rev_pyiter_collect(revs, idx)?;
+ Ok(PyList::new(
+ slf.py(),
+ idx.ancestors(&revs)
+ .map_err(graph_error)?
+ .into_iter()
+ .map(PyRevision::from),
+ )?
+ .into_any()
+ .unbind())
+ })
+ }
+
/// reachableroots
#[pyo3(signature = (*args))]
fn _index_reachableroots2(