Mercurial > hg
comparison rust/hg-cpython/src/cindex.rs @ 48852:e633e660158f
revlog: implement fast_rank retrieval in C
This will be useful in particular to avoid going through the Python interpreter
in native Rust functions.
Differential Revision: https://phab.mercurial-scm.org/D12209
author | pacien <pacien.trangirard@pacien.net> |
---|---|
date | Mon, 21 Feb 2022 18:05:54 +0100 |
parents | 8e8737a1fa7d |
children | 4346be456875 |
comparison
equal
deleted
inserted
replaced
48851:d739cd69bb6a | 48852:e633e660158f |
---|---|
16 }; | 16 }; |
17 use hg::revlog::{Node, RevlogIndex}; | 17 use hg::revlog::{Node, RevlogIndex}; |
18 use hg::{Graph, GraphError, Revision, WORKING_DIRECTORY_REVISION}; | 18 use hg::{Graph, GraphError, Revision, WORKING_DIRECTORY_REVISION}; |
19 use libc::{c_int, ssize_t}; | 19 use libc::{c_int, ssize_t}; |
20 | 20 |
21 const REVLOG_CABI_VERSION: c_int = 2; | 21 const REVLOG_CABI_VERSION: c_int = 3; |
22 | 22 |
23 #[repr(C)] | 23 #[repr(C)] |
24 pub struct Revlog_CAPI { | 24 pub struct Revlog_CAPI { |
25 abi_version: c_int, | 25 abi_version: c_int, |
26 index_length: | 26 index_length: |
27 unsafe extern "C" fn(index: *mut revlog_capi::RawPyObject) -> ssize_t, | 27 unsafe extern "C" fn(index: *mut revlog_capi::RawPyObject) -> ssize_t, |
28 index_node: unsafe extern "C" fn( | 28 index_node: unsafe extern "C" fn( |
29 index: *mut revlog_capi::RawPyObject, | 29 index: *mut revlog_capi::RawPyObject, |
30 rev: ssize_t, | 30 rev: ssize_t, |
31 ) -> *const Node, | 31 ) -> *const Node, |
32 fast_rank: unsafe extern "C" fn( | |
33 index: *mut revlog_capi::RawPyObject, | |
34 rev: ssize_t, | |
35 ) -> ssize_t, | |
32 index_parents: unsafe extern "C" fn( | 36 index_parents: unsafe extern "C" fn( |
33 index: *mut revlog_capi::RawPyObject, | 37 index: *mut revlog_capi::RawPyObject, |
34 rev: c_int, | 38 rev: c_int, |
35 ps: *mut [c_int; 2], | 39 ps: *mut [c_int; 2], |
36 ) -> c_int, | 40 ) -> c_int, |