Skip to content
Snippets Groups Projects
Unverified Commit f0136873 authored by Todd Gamblin's avatar Todd Gamblin
Browse files

performance: reduce system calls required for remove_dead_links

`os.path.exists()` will report False if the target of a symlink doesn't
exist, so we can avoid a costly call to realpath here.
parent 79ddf6cf
No related branches found
No related tags found
No related merge requests found
......@@ -917,10 +917,8 @@ def remove_if_dead_link(path):
Parameters:
path (str): The potential dead link
"""
if os.path.islink(path):
real_path = os.path.realpath(path)
if not os.path.exists(real_path):
os.unlink(path)
if os.path.islink(path) and not os.path.exists(path):
os.unlink(path)
def remove_linked_tree(path):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment