@@ -66,7 +66,7 @@ impl OutputMode {
6666}
6767
6868#[ derive( Clone , Debug , PartialEq , Eq , Hash , Default ) ]
69- pub struct CommandCacheKey {
69+ pub struct CommandFingerprint {
7070 program : OsString ,
7171 args : Vec < OsString > ,
7272 envs : Vec < ( OsString , Option < OsString > ) > ,
@@ -80,11 +80,11 @@ pub struct CommandProfile {
8080
8181#[ derive( Default ) ]
8282pub struct CommandProfiler {
83- stats : Mutex < HashMap < CommandCacheKey , CommandProfile > > ,
83+ stats : Mutex < HashMap < CommandFingerprint , CommandProfile > > ,
8484}
8585
8686impl CommandProfiler {
87- pub fn record_execution ( & self , key : CommandCacheKey , start_time : Instant ) {
87+ pub fn record_execution ( & self , key : CommandFingerprint , start_time : Instant ) {
8888 let mut stats = self . stats . lock ( ) . unwrap ( ) ;
8989 let entry = stats. entry ( key) . or_default ( ) ;
9090 entry. traces . push ( ExecutionTrace :: Executed {
@@ -93,7 +93,7 @@ impl CommandProfiler {
9393 } ) ;
9494 }
9595
96- pub fn record_cache_hit ( & self , key : CommandCacheKey ) {
96+ pub fn record_cache_hit ( & self , key : CommandFingerprint ) {
9797 let mut stats = self . stats . lock ( ) . unwrap ( ) ;
9898 let entry = stats. entry ( key) . or_default ( ) ;
9999 entry. traces . push ( ExecutionTrace :: CacheHit { timestamp : Instant :: now ( ) } ) ;
@@ -113,27 +113,24 @@ impl CommandProfiler {
113113 match trace {
114114 ExecutionTrace :: CacheHit { timestamp } => {
115115 hits += 1 ;
116- println ! ( " - Cache hit at: { :?}" , timestamp ) ;
116+ println ! ( " - Cache hit at: {timestamp :?}" ) ;
117117 }
118118 ExecutionTrace :: Executed { duration, timestamp } => {
119119 runs += 1 ;
120- if max_duration. map_or ( true , |d| * duration > d) {
120+ if max_duration. is_none_or ( |d| * duration > d) {
121121 max_duration = Some ( * duration) ;
122122 }
123- println ! ( " - Executed at: { :?}, duration: {:.2?}" , timestamp , duration ) ;
123+ println ! ( " - Executed at: {timestamp :?}, duration: {duration :.2?}" ) ;
124124 }
125125 }
126126 }
127127
128128 let duration_str = match max_duration {
129- Some ( d) => format ! ( "{:.2?}" , d ) ,
129+ Some ( d) => format ! ( "{d :.2?}" ) ,
130130 None => "-" . into ( ) ,
131131 } ;
132132
133- println ! (
134- " => Summary: {} run(s), {} hit(s), max_duration={}" ,
135- runs, hits, duration_str
136- ) ;
133+ println ! ( "Summary: {runs} run(s), {hits} hit(s), max_duration={duration_str}" ) ;
137134 }
138135 }
139136}
@@ -316,9 +313,9 @@ impl<'a> BootstrapCommand {
316313 }
317314 }
318315
319- pub fn cache_key ( & self ) -> CommandCacheKey {
316+ pub fn cache_key ( & self ) -> CommandFingerprint {
320317 let command = & self . command ;
321- CommandCacheKey {
318+ CommandFingerprint {
322319 program : command. get_program ( ) . into ( ) ,
323320 args : command. get_args ( ) . map ( OsStr :: to_os_string) . collect ( ) ,
324321 envs : command
@@ -505,7 +502,7 @@ pub struct ExecutionContext {
505502
506503#[ derive( Default ) ]
507504pub struct CommandCache {
508- cache : Mutex < HashMap < CommandCacheKey , CommandOutput > > ,
505+ cache : Mutex < HashMap < CommandFingerprint , CommandOutput > > ,
509506}
510507
511508enum CommandState < ' a > {
@@ -516,7 +513,7 @@ enum CommandState<'a> {
516513 stdout : OutputMode ,
517514 stderr : OutputMode ,
518515 executed_at : & ' a Location < ' a > ,
519- cache_key : CommandCacheKey ,
516+ cache_key : CommandFingerprint ,
520517 start_time : Instant ,
521518 } ,
522519}
@@ -533,11 +530,11 @@ pub struct DeferredCommand<'a> {
533530}
534531
535532impl CommandCache {
536- pub fn get ( & self , key : & CommandCacheKey ) -> Option < CommandOutput > {
533+ pub fn get ( & self , key : & CommandFingerprint ) -> Option < CommandOutput > {
537534 self . cache . lock ( ) . unwrap ( ) . get ( key) . cloned ( )
538535 }
539536
540- pub fn insert ( & self , key : CommandCacheKey , output : CommandOutput ) {
537+ pub fn insert ( & self , key : CommandFingerprint , output : CommandOutput ) {
541538 self . cache . lock ( ) . unwrap ( ) . insert ( key, output) ;
542539 }
543540}
0 commit comments