@@ -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
use std:: fmt:: Formatter ;
8
8
9
9
/// A way to constrain all [tree-edits](Editor) to a given subtree.
@@ -45,7 +45,7 @@ impl<'a> Editor<'a> {
45
45
Editor {
46
46
find,
47
47
object_hash,
48
- trees : gix_hashtable :: HashMap :: from_iter ( Some ( ( empty_path_hash ( ) , root) ) ) ,
48
+ trees : HashMap :: from_iter ( Some ( ( empty_path ( ) , root) ) ) ,
49
49
path_buf : Vec :: with_capacity ( 256 ) . into ( ) ,
50
50
tree_buf : Vec :: with_capacity ( 512 ) ,
51
51
}
@@ -160,7 +160,7 @@ impl<'a> Editor<'a> {
160
160
}
161
161
Err ( err) => {
162
162
let root_tree = parents. into_iter ( ) . next ( ) . expect ( "root wasn't consumed yet" ) ;
163
- self . trees . insert ( path_hash ( & root_tree. 1 ) , root_tree. 2 ) ;
163
+ self . trees . insert ( root_tree. 1 , root_tree. 2 ) ;
164
164
return Err ( err) ;
165
165
}
166
166
}
@@ -179,11 +179,11 @@ impl<'a> Editor<'a> {
179
179
}
180
180
WriteMode :: FromCursor => { }
181
181
}
182
- self . trees . insert ( path_hash ( & rela_path) , tree) ;
182
+ self . trees . insert ( rela_path, tree) ;
183
183
return Ok ( root_tree_id) ;
184
184
}
185
185
Err ( err) => {
186
- self . trees . insert ( path_hash ( & rela_path) , tree) ;
186
+ self . trees . insert ( rela_path, tree) ;
187
187
return Err ( err) ;
188
188
}
189
189
}
@@ -297,8 +297,8 @@ impl<'a> Editor<'a> {
297
297
push_path_component ( & mut self . path_buf , name) ;
298
298
let path_id = path_hash ( & self . path_buf ) ;
299
299
cursor = match self . trees . entry ( path_id) {
300
- Entry :: Occupied ( e) => e. into_mut ( ) ,
301
- Entry :: Vacant ( e) => e. insert (
300
+ hash_map :: Entry :: Occupied ( e) => e. into_mut ( ) ,
301
+ hash_map :: Entry :: Vacant ( e) => e. insert (
302
302
if let Some ( tree_id) = tree_to_lookup. filter ( |tree_id| !tree_id. is_empty_tree ( ) ) {
303
303
self . find . find_tree ( & tree_id, & mut self . tree_buf ) ?. into ( )
304
304
} else {
@@ -317,7 +317,7 @@ impl<'a> Editor<'a> {
317
317
/// This is useful if the same editor is re-used for various trees.
318
318
pub fn set_root ( & mut self , root : Tree ) -> & mut Self {
319
319
self . trees . clear ( ) ;
320
- self . trees . insert ( empty_path_hash ( ) , root) ;
320
+ self . trees . insert ( empty_path ( ) , root) ;
321
321
self
322
322
}
323
323
}
@@ -420,14 +420,12 @@ fn filename(path: &BStr) -> &BStr {
420
420
path. rfind_byte ( b'/' ) . map_or ( path, |pos| & path[ pos + 1 ..] )
421
421
}
422
422
423
- fn empty_path_hash ( ) -> ObjectId {
424
- gix_features :: hash :: hasher ( gix_hash :: Kind :: Sha1 ) . digest ( ) . into ( )
423
+ fn empty_path ( ) -> BString {
424
+ BString :: default ( )
425
425
}
426
426
427
- fn path_hash ( path : & [ u8 ] ) -> ObjectId {
428
- let mut hasher = gix_features:: hash:: hasher ( gix_hash:: Kind :: Sha1 ) ;
429
- hasher. update ( path) ;
430
- hasher. digest ( ) . into ( )
427
+ fn path_hash ( path : & [ u8 ] ) -> BString {
428
+ path. to_vec ( ) . into ( )
431
429
}
432
430
433
431
fn push_path_component ( base : & mut BString , component : & [ u8 ] ) -> usize {
0 commit comments