Skip to content

Conversation

mikelxk
Copy link

@mikelxk mikelxk commented Mar 20, 2025

Compile with latest emsdk for emscripten-core/emscripten#23937
This improve perf by removing prototype assigning and a fixed rare bug on Function not being able to called due to some weird prototype assigning issue.

function newFunc(constructor, argumentList) {
if (!(constructor instanceof Function)) {
throw new TypeError(`new_ called with constructor type ${typeof(constructor)} which is not a function`);
}
/*
* Previously, the following line was just:
* function dummy() {};
* Unfortunately, Chrome was preserving 'dummy' as the object's name, even
* though at creation, the 'dummy' has the correct constructor name. Thus,
* objects created with IMVU.new would show up in the debugger as 'dummy',
* which isn't very helpful. Using IMVU.createNamedFunction addresses the
* issue. Doubly-unfortunately, there's no way to write a test for this
* behavior. -NRD 2013.02.22
*/
var dummy = createNamedFunction(constructor.name || 'unknownFunctionName', function(){});
dummy.prototype = constructor.prototype;
var obj = new dummy;
var r = constructor.apply(obj, argumentList);
return (r instanceof Object) ? r : obj;
}

@richgel999
Copy link
Contributor

Thanks - I'll try compiling it with the latest EMSDK myself and see if I get the same change. (This is a compiler generated file.)

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