Mercurial > public > mercurial-scm > hg
diff rust/hg-cpython/src/dagops.rs @ 43269:33fe96a5c522
rust-cpython: removed now useless py_set() conversion
In rust-cpython 0.3.0, HashSets implement the appropriate
ToPythonObject, we can therefore get rid of this hacky conversion.
There still remains an inefficiency in `MissingAncestors.bases()`:
we have to clone, because `to_py_object()` requires full ownership.
However:
- the only use case outside of unit tests used to be from
`setdiscovery.partialdiscovery` which is now fully implemented
in Rust.
- it's not worse than what `py_set()` used to do
Differential Revision: https://phab.mercurial-scm.org/D7120
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Mon, 30 Sep 2019 16:31:53 -0400 |
parents | 326fdce22fb2 |
children | f98f0e3ddaa1 |
line wrap: on
line diff
--- a/rust/hg-cpython/src/dagops.rs Tue Oct 15 22:02:34 2019 -0400 +++ b/rust/hg-cpython/src/dagops.rs Mon Sep 30 16:31:53 2019 -0400 @@ -10,9 +10,7 @@ //! //! From Python, this will be seen as `mercurial.rustext.dagop` use crate::{ - cindex::Index, - conversion::{py_set, rev_pyiter_collect}, - exceptions::GraphError, + cindex::Index, conversion::rev_pyiter_collect, exceptions::GraphError, }; use cpython::{PyDict, PyModule, PyObject, PyResult, Python}; use hg::dagops; @@ -26,11 +24,11 @@ py: Python, index: PyObject, revs: PyObject, -) -> PyResult<PyObject> { +) -> PyResult<HashSet<Revision>> { let mut as_set: HashSet<Revision> = rev_pyiter_collect(py, &revs)?; dagops::retain_heads(&Index::new(py, index)?, &mut as_set) .map_err(|e| GraphError::pynew(py, e))?; - py_set(py, &as_set) + Ok(as_set) } /// Create the module, with `__package__` given from parent