comparison rust/hg-core/src/revlog.rs @ 44182:9896a8d0d3d2

rust-node: handling binary Node prefix Parallel to the inner signatures of the nodetree functions in revlog.c, we'll have to handle prefixes of `Node` in binary form. Another motivation is that it allows to convert from full Node references to `NodePrefixRef` without copy. This is expected to be by far the most common case in practice. There's a slight complication due to the fact that we'll be sometimes interested in prefixes with an odd number of hexadecimal digits, which translates in binary form by a last byte in which only the highest weight 4 bits are considered. This is totally transparent for callers and could be revised once we have proper means to measure performance. The C implementation does the same, passing the length in nybbles as function arguments. Because Rust byte slices already have a length, we carry the even/odd informaton as a boolean, to avoid introducing logical redundancies and the related potential inconsistency bugs. There are a few candidates for inlining here, but we refrain from such premature optimizations, letting the compiler decide. Differential Revision: https://phab.mercurial-scm.org/D7790
author Georges Racinet <georges.racinet@octobus.net>
date Fri, 27 Dec 2019 23:04:18 +0100
parents 3fb39dc2e356
children 26114bd6ec60
comparison
equal deleted inserted replaced
44181:3fb39dc2e356 44182:9896a8d0d3d2
5 // GNU General Public License version 2 or any later version. 5 // GNU General Public License version 2 or any later version.
6 //! Mercurial concepts for handling revision history 6 //! Mercurial concepts for handling revision history
7 7
8 pub mod node; 8 pub mod node;
9 pub mod nodemap; 9 pub mod nodemap;
10 pub use node::{Node, NodeError}; 10 pub use node::{Node, NodeError, NodePrefix, NodePrefixRef};
11 11
12 /// Mercurial revision numbers 12 /// Mercurial revision numbers
13 /// 13 ///
14 /// As noted in revlog.c, revision numbers are actually encoded in 14 /// As noted in revlog.c, revision numbers are actually encoded in
15 /// 4 bytes, and are liberally converted to ints, whence the i32 15 /// 4 bytes, and are liberally converted to ints, whence the i32