comparison rust/hg-cpython/src/revlog.rs @ 46431:645ee7225fab

rust: Make NodePrefix allocation-free and Copy, remove NodePrefixRef The `*Ref` struct only existed to avoid allocating `Vec`s when cloning `NodePrefix`, but we can avoid having `Vec` in the first place by using an inline array instead. This makes `NodePrefix` 21 bytes (with 1 for the length) which is smaller than before as `Vec` alone is 24 bytes. Differential Revision: https://phab.mercurial-scm.org/D9863
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 25 Jan 2021 11:48:47 +0100
parents 5893706af3de
children 18a261b11b20
comparison
equal deleted inserted replaced
46430:b84c3d43ff2e 46431:645ee7225fab
62 def get_rev(&self, node: PyBytes) -> PyResult<Option<Revision>> { 62 def get_rev(&self, node: PyBytes) -> PyResult<Option<Revision>> {
63 let opt = self.get_nodetree(py)?.borrow(); 63 let opt = self.get_nodetree(py)?.borrow();
64 let nt = opt.as_ref().unwrap(); 64 let nt = opt.as_ref().unwrap();
65 let idx = &*self.cindex(py).borrow(); 65 let idx = &*self.cindex(py).borrow();
66 let node = node_from_py_bytes(py, &node)?; 66 let node = node_from_py_bytes(py, &node)?;
67 nt.find_bin(idx, (&node).into()).map_err(|e| nodemap_error(py, e)) 67 nt.find_bin(idx, node.into()).map_err(|e| nodemap_error(py, e))
68 } 68 }
69 69
70 /// same as `get_rev()` but raises a bare `error.RevlogError` if node 70 /// same as `get_rev()` but raises a bare `error.RevlogError` if node
71 /// is not found. 71 /// is not found.
72 /// 72 ///