Skip to content
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

Remove top-level await #268

Merged
merged 6 commits into from
Apr 17, 2024
Merged

Remove top-level await #268

merged 6 commits into from
Apr 17, 2024

Conversation

mitschabaude
Copy link
Collaborator

@mitschabaude mitschabaude commented Apr 15, 2024

companion for o1-labs/o1js#1583

@@ -23,13 +21,11 @@ let workerPromise;
*/
let numWorkers = undefined;

let isInitialized = false;
async function initializeBindings() {
wasm = plonkWasm();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved this here to make the initial loading time even faster (< 20ms)

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any use in returning from the function early if wasm is already defined? Let's say we accidentally call initializeBindings() twice, does that mean we have to wait for loading twice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah that's very important! I moved the early return logic into snarky.web.js, through which this function will always be called

@mitschabaude mitschabaude merged commit 8a489b8 into main Apr 17, 2024
1 check passed
@mitschabaude mitschabaude deleted the feature/no-top-level-await branch April 17, 2024 05:40
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.

3 participants