Skip to content

Commit

Permalink
Remove unnecessary prototype creation
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuanjl committed Jan 6, 2021
1 parent 9cd87d6 commit 9c60dc4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
10 changes: 2 additions & 8 deletions lib/Runtime/Library/JavascriptAsyncGeneratorFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ Var JavascriptAsyncGeneratorFunction::EntryAsyncGeneratorFunctionImplementation(

auto* asyncGeneratorFn = VarTo<JavascriptAsyncGeneratorFunction>(function);
auto* library = scriptContext->GetLibrary();
auto* prototype = library->CreateAsyncGeneratorConstructorPrototypeObject();
auto* prototype = VarTo<DynamicObject>(JavascriptOperators::GetPropertyNoCache(
function, Js::PropertyIds::prototype, scriptContext));
auto* scriptFn = asyncGeneratorFn->GetGeneratorVirtualScriptFunction();
auto* generator = library->CreateAsyncGenerator(args, scriptFn, prototype);

Expand All @@ -62,12 +63,5 @@ Var JavascriptAsyncGeneratorFunction::EntryAsyncGeneratorFunctionImplementation(

generator->SetSuspendedStart();

// Set the prototype from constructor
JavascriptOperators::OrdinaryCreateFromConstructor(
function,
generator,
prototype,
scriptContext);

return generator;
}
10 changes: 2 additions & 8 deletions lib/Runtime/Library/JavascriptGeneratorFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ using namespace Js;
auto* library = scriptContext->GetLibrary();
auto* generatorFunction = VarTo<JavascriptGeneratorFunction>(function);

DynamicObject* prototype = library->CreateGeneratorConstructorPrototypeObject();
DynamicObject* prototype = VarTo<DynamicObject>(JavascriptOperators::GetPropertyNoCache(
function, Js::PropertyIds::prototype, scriptContext));

JavascriptGenerator* generator = library->CreateGenerator(
args,
Expand All @@ -127,13 +128,6 @@ using namespace Js;

generator->SetSuspendedStart();

// Set the prototype from constructor
JavascriptOperators::OrdinaryCreateFromConstructor(
function,
generator,
prototype,
scriptContext);

return generator;
}

Expand Down

0 comments on commit 9c60dc4

Please sign in to comment.