Mercurial > public > mercurial-scm > hg
changeset 52800:ebcbd2b7a3b6
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`.
author | Georges Racinet <georges.racinet@cloudcrane.io> |
---|---|
date | Mon, 23 Dec 2024 21:03:38 +0100 |
parents | 798355e46d03 |
children | 419e60ff3c44 |
files | rust/hg-pyo3/src/revlog/mod.rs |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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(