Skip to content

Remove unnecessary 'queuedImports.splice()' calls #232

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

Closed

Conversation

andy-hanson
Copy link
Contributor

I noticed that queuedImports is never looked at again after this loop. Since queuedImports.splice(i, 1) is equivalent to i++ if we don't care about the state of queuedImports after the loop, we can just convert this to an ordinary for-of loop.
As of this PR, queuedImports is only referenced twice: once to write to in initializeImports, and once to loop over here.

@@ -490,40 +490,33 @@ export class Program extends DiagnosticEmitter {
}

// queued imports should be resolvable now through traversing exports and queued exports
for (let i = 0; i < queuedImports.length;) {
let queuedImport = queuedImports[i];
for (const queuedImport of queuedImports) {
Copy link
Member

Choose a reason for hiding this comment

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

Looks good, but can we keep the plain for-loop here? Just to be sure, because for-of isn't yet supported when compiling to WASM (somewhat due to the lack of iterators), even though we don't compile the compiler itself to WASM yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What to do about for-of loops over maps?

@andy-hanson
Copy link
Contributor Author

This PR subsumed by #249 anyway.

@andy-hanson andy-hanson closed this Sep 9, 2018
@andy-hanson andy-hanson deleted the queuedImports_splice branch September 9, 2018 17:15
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