File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -262,11 +262,11 @@ impl DownloaderState {
262
262
PeerBlobState :: new ( subscription_id) ,
263
263
) ;
264
264
}
265
- if ! self . discovery . contains_key ( & request. hash ) {
265
+ if let std :: collections :: btree_map :: Entry :: Vacant ( e ) = self . discovery . entry ( request. hash ) {
266
266
// start a discovery task
267
267
let id = self . discovery_id_gen . next ( ) ;
268
268
evs. push ( Event :: StartDiscovery { hash, id } ) ;
269
- self . discovery . insert ( request . hash , id) ;
269
+ e . insert ( id) ;
270
270
}
271
271
self . downloads . insert ( id, DownloadState :: new ( request) ) ;
272
272
self . check_completion ( hash, Some ( id) , evs) ?;
@@ -825,9 +825,7 @@ impl Downloads {
825
825
id : PeerDownloadId ,
826
826
) -> Option < ( & DownloadId , & mut DownloadState ) > {
827
827
self . by_id
828
- . iter_mut ( )
829
- . filter ( |( _, v) | v. peer_downloads . iter ( ) . any ( |( _, state) | state. id == id) )
830
- . next ( )
828
+ . iter_mut ( ) . find ( |( _, v) | v. peer_downloads . iter ( ) . any ( |( _, state) | state. id == id) )
831
829
}
832
830
}
833
831
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ pub enum BaoBlobSize {
52
52
}
53
53
54
54
impl BaoBlobSize {
55
- /// Create a new `BaoFileSize ` with the given size and verification status.
55
+ /// Create a new `BaoBlobSize ` with the given size and verification status.
56
56
pub fn new ( size : u64 , verified : bool ) -> Self {
57
57
if verified {
58
58
BaoBlobSize :: Verified ( size)
You can’t perform that action at this time.
0 commit comments