Skip to content

Commit 2730ce9

Browse files
committed
rename CommandCacheKey to CommandFingerprint
1 parent a8046bb commit 2730ce9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/bootstrap/src/utils/exec.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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)]
8282
pub struct CommandProfiler {
83-
stats: Mutex<HashMap<CommandCacheKey, CommandProfile>>,
83+
stats: Mutex<HashMap<CommandFingerprint, CommandProfile>>,
8484
}
8585

8686
impl 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() });
@@ -316,9 +316,9 @@ impl<'a> BootstrapCommand {
316316
}
317317
}
318318

319-
pub fn cache_key(&self) -> CommandCacheKey {
319+
pub fn cache_key(&self) -> CommandFingerprint {
320320
let command = &self.command;
321-
CommandCacheKey {
321+
CommandFingerprint {
322322
program: command.get_program().into(),
323323
args: command.get_args().map(OsStr::to_os_string).collect(),
324324
envs: command
@@ -505,7 +505,7 @@ pub struct ExecutionContext {
505505

506506
#[derive(Default)]
507507
pub struct CommandCache {
508-
cache: Mutex<HashMap<CommandCacheKey, CommandOutput>>,
508+
cache: Mutex<HashMap<CommandFingerprint, CommandOutput>>,
509509
}
510510

511511
enum CommandState<'a> {
@@ -516,7 +516,7 @@ enum CommandState<'a> {
516516
stdout: OutputMode,
517517
stderr: OutputMode,
518518
executed_at: &'a Location<'a>,
519-
cache_key: CommandCacheKey,
519+
cache_key: CommandFingerprint,
520520
start_time: Instant,
521521
},
522522
}
@@ -533,11 +533,11 @@ pub struct DeferredCommand<'a> {
533533
}
534534

535535
impl CommandCache {
536-
pub fn get(&self, key: &CommandCacheKey) -> Option<CommandOutput> {
536+
pub fn get(&self, key: &CommandFingerprint) -> Option<CommandOutput> {
537537
self.cache.lock().unwrap().get(key).cloned()
538538
}
539539

540-
pub fn insert(&self, key: CommandCacheKey, output: CommandOutput) {
540+
pub fn insert(&self, key: CommandFingerprint, output: CommandOutput) {
541541
self.cache.lock().unwrap().insert(key, output);
542542
}
543543
}

0 commit comments

Comments
 (0)