aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAria Shrimpton <me@aria.rip>2024-01-23 13:24:36 +0000
committerAria Shrimpton <me@aria.rip>2024-01-23 13:24:36 +0000
commit215355ea337140d7b5bfaaece3cc0b1dd2c71663 (patch)
tree32f30684c6b4e239febe11cb8cc2888781edf02c
parent1a9b3f80573898cb14aaff7a5b176ba700fef750 (diff)
more efficient caching of profiling information
-rw-r--r--src/crates/candelabra/src/cache.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/crates/candelabra/src/cache.rs b/src/crates/candelabra/src/cache.rs
index ccb61fd..4546fbe 100644
--- a/src/crates/candelabra/src/cache.rs
+++ b/src/crates/candelabra/src/cache.rs
@@ -121,12 +121,27 @@ pub fn gen_tree_hash(dir: &Utf8Path) -> Result<u64> {
// TODO: ignore target, etc
let mut hasher = DefaultHasher::new();
- for f in glob(&format!("{}/**/*", dir)).unwrap() {
- let f = f?;
- let as_str = f.as_os_str().to_str().unwrap();
- if as_str.contains("target/") || as_str.contains(".pr.rs") {
+ let mut files = glob(&format!("{}/**/*", dir))
+ .unwrap()
+ .map(|r| r.map(|p| Utf8PathBuf::from_path_buf(p).unwrap()))
+ .collect::<Result<Vec<_>, _>>()?;
+
+ // remove target/
+ files.retain(|p| !p.as_str().contains("target/"));
+
+ // ignore files generated by primrose
+ let ignore = files
+ .iter()
+ .filter(|p| p.as_str().contains(".pr.rs"))
+ .map(|p| Utf8PathBuf::from(p.to_string().replace(".pr.rs", "")))
+ .collect::<Vec<_>>();
+
+ // actual hashing
+ for f in files {
+ if ignore.contains(&f) {
continue;
}
+ dbg!(&f);
let modified = metadata(f)?.modified()?;
modified.hash(&mut hasher);