Skip to content

Commit 591e9d8

Browse files
committed
Simplify up_to_date to call metadata once.
This also eliminates a use of a `Path` convenience function, in support of rust-lang#80741, refactoring `std::path` to focus on pure data structures and algorithms.
1 parent da305a2 commit 591e9d8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/build_helper/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,11 @@ pub fn mtime(path: &Path) -> SystemTime {
172172
///
173173
/// Uses last-modified time checks to verify this.
174174
pub fn up_to_date(src: &Path, dst: &Path) -> bool {
175-
if !dst.exists() {
176-
return false;
177-
}
178-
let threshold = mtime(dst);
175+
let dst_meta = match fs::metadata(dst) {
176+
Ok(meta) => meta,
177+
Err(_) => return false,
178+
};
179+
let threshold = dst_meta.modified().unwrap_or(UNIX_EPOCH);
179180
let meta = match fs::metadata(src) {
180181
Ok(meta) => meta,
181182
Err(e) => panic!("source {:?} failed to get metadata: {}", src, e),

0 commit comments

Comments
 (0)