Skip to content

Minimize stat calls #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 28, 2013
Merged

Minimize stat calls #41

merged 2 commits into from
Jan 28, 2013

Conversation

andralex
Copy link
Member

Minimize stat calls. Also a few refactorings.

yap("stat ", workDir);
DirEntry workDirEntry;
const workDirExists =
collectException(workDirEntry = dirEntry(workDir)) is null;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simpler:

const workDirExists = assertNotThrown(workDirEntry = dirEntry(workDir));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't seem to do what we need here.

@@ -205,7 +214,8 @@ int main(string[] args)
}

// Have at it
if (isNewer(root, exe) || anyNewerThan(myDeps.keys, exe))
auto exeTime = exe.timeLastModified(SysTime.min);
if (chain(root.only, myDeps.byKey).array.anyNewerThan(exeTime))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heheh, .array again. I guess it won't hurt much. anyNewerThan should ideally take a range instead of an array, but let's leave that for some future pull request.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah. This script's running time is dominated by system calls and processes spawned. The equivalent written in a traditional scripting language would do plenty more allocation and would be likely a bit slower anyway.

alexrp added a commit that referenced this pull request Jan 28, 2013
@alexrp alexrp merged commit 4692c52 into dlang:master Jan 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants