From 2366f9e588b2d90da673ef0020dadfdbdca710aa Mon Sep 17 00:00:00 2001 From: ahochheiden Date: Fri, 17 May 2024 21:35:05 +0000 Subject: [PATCH] Bug 1896688 - Prevent unnecessary os.stat call in jar.py r=sergesanspaille If the destination file doesn't exist, we don't need to check the current file's time, and we can just write or symlink regardless. Differential Revision: https://phabricator.services.mozilla.com/D210330 --- python/mozbuild/mozbuild/jar.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/mozbuild/mozbuild/jar.py b/python/mozbuild/mozbuild/jar.py index 0559a12c29d5..1bf279f711d0 100644 --- a/python/mozbuild/mozbuild/jar.py +++ b/python/mozbuild/mozbuild/jar.py @@ -517,7 +517,9 @@ class JarMaker(object): # copy or symlink if newer - if getModTime(realsrc) > outHelper.getDestModTime(e.output): + # if the output doesn't exist, we can skip an os.stat call + out_mod_time = outHelper.getDestModTime(e.output) + if out_mod_time == localtime(0) or getModTime(realsrc) > out_mod_time: if self.outputFormat == "symlink": outHelper.symlink(realsrc, out) return