Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,10 +1107,13 @@ def make_bad(target=None):
end = raw.rindex(']')
body = raw[start + 1:end].split(',')
if shared.Settings.EMULATED_FUNCTION_POINTERS:
# this speeds up this section when all_implemented is very big > 150000
notinImplemented = list(set(body) - set(all_implemented))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wouldn't this be a lot faster if you dropped the list() since "if x in set" is O(1) rather than O(n) for "if x in list"?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In fact we change get_all_implemented to return a set then I think that should improve performance here and elsewhere significantly.

As far as I can tell the ordering of all_implemented is not important anywhere.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I took a stab a this, I hope you don't mind: #9435

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks @sbc100 let me test out your changes report the numbers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks @sbc100 the reduction is similar. but your changes are better. Thanks! going to close this


def receive(item):
if item == '0':
return item
if item not in all_implemented:
if item in notinImplemented:
# this is not implemented; it would normally be wrapped, but with emulation, we just use it directly outside
return item
in_table.add(item)
Expand Down