Skip to content

Commit ffb52c9

Browse files
authored
Use shorthand object initialization for wasmImports where possible. NFC (#21779)
As of today this doesn't do much since only the invoke_xx function are not mangled using the leading underscore. If we ever manage to remove that mangling then this will effect basically all imports.
1 parent d7fc511 commit ffb52c9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/emscripten.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,15 @@ def create_sending(metadata, library_symbols):
854854
# This prevents closure compiler from minifying the field names in this
855855
# object.
856856
prefix = '/** @export */\n '
857-
return '{\n ' + ',\n '.join(f'{prefix}{k}: {v}' for k, v in sorted_items) + '\n}'
857+
858+
elems = []
859+
for k, v in sorted_items:
860+
if k == v:
861+
elems.append(f'{prefix}{k}')
862+
else:
863+
elems.append(f'{prefix}{k}: {v}')
864+
865+
return '{\n ' + ',\n '.join(elems) + '\n}'
858866

859867

860868
def make_export_wrappers(function_exports):

0 commit comments

Comments
 (0)