Skip to content

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