Mercurial > public > mercurial-scm > hg
diff rust/hg-pyo3/src/revlog/mod.rs @ 52803:3bfd80a277be
rust-pyo3-revlog: _index_pack_header
Very straightforward. I suppose it is not in a hot loop, but if
it is, given what `Index::pack_header` actually does, it could
be replaced by a straight implementation without unlocking anything.
author | Georges Racinet <georges.racinet@cloudcrane.io> |
---|---|
date | Mon, 23 Dec 2024 23:42:06 +0100 |
parents | 8cb1a561c5ac |
children | 6c6cfb89a4f1 |
line wrap: on
line diff
--- a/rust/hg-pyo3/src/revlog/mod.rs Mon Dec 23 21:46:51 2024 +0100 +++ b/rust/hg-pyo3/src/revlog/mod.rs Mon Dec 23 23:42:06 2024 +0100 @@ -419,6 +419,16 @@ Ok(()) } + /// return a binary packed version of the header + fn _index_pack_header( + slf: &Bound<'_, Self>, + header: i32, + ) -> PyResult<Py<PyBytes>> { + let packed = + Self::with_index_read(slf, |idx| Ok(idx.pack_header(header)))?; + Ok(PyBytes::new(slf.py(), &packed).unbind()) + } + /// reachableroots #[pyo3(signature = (*args))] fn _index_reachableroots2(