Skip to content

Refactor temporary file handling for efficiency #1865

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 1 commit into from
Dec 11, 2018

Conversation

jcollins-g
Copy link
Contributor

Fixes a rare problem where incrementing the file counter asynchronously with determining the filename could result in collisions. Also combines all tool temporary files into a single manager, and reduces the number of ToolRunner objects by pairing them directly with ToolConfiguration objects. This means no longer creating and then destroying a directory for each tool-using ModelElement. Reduces runtime another 10 percent or so for Flutter.

@googlebot googlebot added the cla: yes Google CLA check succeeded. label Dec 8, 2018
}
_instance = null;
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't you just delete this line now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The linter complains if I do that; I can leave the return in, or add a lint exclusion.


Future<File> _createTemporaryFile() async {
int _temporaryFileCount = 0;
Future<File> createTemporaryFile() async {
_temporaryFileCount++;
File tempFile = new File(pathLib.join(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Couldn't this just use createTemp on a Directory to avoid needing to keep track of the _temporaryFileCount? I suppose it doesn't matter that much, but it seemed like what createTemp exists to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose it could. createTemp however is a bit overkill as it is intended to prevent collisions between applications, not just within the same application. Having the integer numbers in the name I actually like, since it makes it a little easier to see what's going on under the hood.

@jcollins-g jcollins-g merged commit 06ad7ce into master Dec 11, 2018
@kevmoo kevmoo deleted the temp-file-refactor branch January 18, 2019 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants