@@ -2,8 +2,8 @@ use crate::tree::{Editor, EntryKind};
2
2
use crate :: { tree, Tree } ;
3
3
use bstr:: { BStr , BString , ByteSlice , ByteVec } ;
4
4
use gix_hash:: ObjectId ;
5
- use gix_hashtable:: hash_map:: Entry ;
6
5
use std:: cmp:: Ordering ;
6
+ use std:: collections:: { hash_map, HashMap } ;
7
7
8
8
/// A way to constrain all [tree-edits](Editor) to a given subtree.
9
9
pub struct Cursor < ' a , ' find > {
@@ -24,7 +24,7 @@ impl<'a> Editor<'a> {
24
24
Editor {
25
25
find,
26
26
object_hash,
27
- trees : gix_hashtable :: HashMap :: from_iter ( Some ( ( empty_path_hash ( ) , root) ) ) ,
27
+ trees : HashMap :: from_iter ( Some ( ( empty_path ( ) , root) ) ) ,
28
28
path_buf : Vec :: with_capacity ( 256 ) . into ( ) ,
29
29
tree_buf : Vec :: with_capacity ( 512 ) ,
30
30
}
@@ -259,8 +259,8 @@ impl<'a> Editor<'a> {
259
259
push_path_component ( & mut self . path_buf , name) ;
260
260
let path_id = path_hash ( & self . path_buf ) ;
261
261
cursor = match self . trees . entry ( path_id) {
262
- Entry :: Occupied ( e) => e. into_mut ( ) ,
263
- Entry :: Vacant ( e) => e. insert (
262
+ hash_map :: Entry :: Occupied ( e) => e. into_mut ( ) ,
263
+ hash_map :: Entry :: Vacant ( e) => e. insert (
264
264
if let Some ( tree_id) = tree_to_lookup. filter ( |tree_id| !tree_id. is_empty_tree ( ) ) {
265
265
self . find . find_tree ( & tree_id, & mut self . tree_buf ) ?. into ( )
266
266
} else {
@@ -279,7 +279,7 @@ impl<'a> Editor<'a> {
279
279
/// This is useful if the same editor is re-used for various trees.
280
280
pub fn set_root ( & mut self , root : Tree ) -> & mut Self {
281
281
self . trees . clear ( ) ;
282
- self . trees . insert ( empty_path_hash ( ) , root) ;
282
+ self . trees . insert ( empty_path ( ) , root) ;
283
283
self
284
284
}
285
285
}
@@ -387,14 +387,12 @@ fn filename(path: &BStr) -> &BStr {
387
387
path. rfind_byte ( b'/' ) . map_or ( path, |pos| & path[ pos + 1 ..] )
388
388
}
389
389
390
- fn empty_path_hash ( ) -> ObjectId {
391
- gix_features :: hash :: hasher ( gix_hash :: Kind :: Sha1 ) . digest ( ) . into ( )
390
+ fn empty_path ( ) -> BString {
391
+ BString :: default ( )
392
392
}
393
393
394
- fn path_hash ( path : & [ u8 ] ) -> ObjectId {
395
- let mut hasher = gix_features:: hash:: hasher ( gix_hash:: Kind :: Sha1 ) ;
396
- hasher. update ( path) ;
397
- hasher. digest ( ) . into ( )
394
+ fn path_hash ( path : & [ u8 ] ) -> BString {
395
+ path. to_vec ( ) . into ( )
398
396
}
399
397
400
398
fn push_path_component ( base : & mut BString , component : & [ u8 ] ) -> usize {
0 commit comments