-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Fix cubic runtime complexity for collecting source/import files. #1079
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks quite reasonable to me (though I am not that familiar with the DUB internals yet).
@@ -149,14 +149,14 @@ struct BuildSettings { | |||
// add string import files (avoids file name duplicates in addition to path duplicates) | |||
private void addSI(ref string[] arr, in string[] vals) | |||
{ | |||
outer: | |||
bool[string] existing; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A next iteration could cache this as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I was a bit afraid to forget a place where it could get out of sync, because the arrays are public fields, so I wanted to leave that to a more in-depth optimization attempt.
Okay, since this is just a local change, I'm also pretty confident that it should be without mistakes. I'll rebase and merge after Travis passes, unless any issues come up. |
This is still not very efficient, but now has a finite runtime for large numbers of files.
cbe25ea
to
a2e8923
Compare
See vibe-d/vibe.d#1690.
This is still not very efficient, doing several temporary allocations and copies, but replaces cubic runtime by almost linear (except for allocation and AA creation times).