diff rust/hg-core/src/dirstate.rs @ 47138:cd8ca38fccff

rust: Use `&HgPath` instead of `&HgPathBuf` in may APIs Getting the former (through `Deref`) is almost the only useful thing one can do with the latter anyway. With this changes, API become more flexible for the "provider" of these paths which may store something else that Deref?s to HgPath, such as `std::borrow::Cow<HgPath>`. Using `Cow` can help reduce memory alloactions and copying. Differential Revision: https://phab.mercurial-scm.org/D10558
author Simon Sapin <simon.sapin@octobus.net>
date Fri, 30 Apr 2021 19:57:46 +0200
parents be579775c2d9
children 4ee9f419c52e
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate.rs	Fri Apr 30 18:24:54 2021 +0200
+++ b/rust/hg-core/src/dirstate.rs	Fri Apr 30 19:57:46 2021 +0200
@@ -7,7 +7,8 @@
 
 use crate::errors::HgError;
 use crate::revlog::Node;
-use crate::{utils::hg_path::HgPathBuf, FastHashMap};
+use crate::utils::hg_path::{HgPath, HgPathBuf};
+use crate::FastHashMap;
 use bytes_cast::{unaligned, BytesCast};
 use std::convert::TryFrom;
 
@@ -76,11 +77,11 @@
 
 pub type StateMap = FastHashMap<HgPathBuf, DirstateEntry>;
 pub type StateMapIter<'a> =
-    Box<dyn Iterator<Item = (&'a HgPathBuf, &'a DirstateEntry)> + Send + 'a>;
+    Box<dyn Iterator<Item = (&'a HgPath, &'a DirstateEntry)> + Send + 'a>;
 
 pub type CopyMap = FastHashMap<HgPathBuf, HgPathBuf>;
 pub type CopyMapIter<'a> =
-    Box<dyn Iterator<Item = (&'a HgPathBuf, &'a HgPathBuf)> + Send + 'a>;
+    Box<dyn Iterator<Item = (&'a HgPath, &'a HgPath)> + Send + 'a>;
 
 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
 pub enum EntryState {