Skip to content

Commit 50e9328

Browse files
committed
Convert prototype traversal to an iterative loop instead of recursive.
1 parent e0012ee commit 50e9328

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

lib/Runtime/Language/JavascriptOperators.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10032,22 +10032,23 @@ namespace Js
1003210032
return true;
1003310033
}
1003410034

10035+
// Checks to see if the specified object (which should be a prototype object)
10036+
// contains a proxy anywhere in the prototype chain.
1003510037
bool JavascriptOperators::CheckIfPrototypeChainContainsProxyObject(RecyclableObject* prototype)
1003610038
{
1003710039
Assert(JavascriptOperators::IsObjectOrNull(prototype));
1003810040

10039-
if (prototype->GetTypeId() == TypeIds_Null)
10041+
while (prototype->GetTypeId() != TypeIds_Null)
1004010042
{
10041-
return false;
10042-
}
10043-
else if (prototype->GetTypeId() == TypeIds_Proxy)
10044-
{
10045-
return true;
10046-
}
10047-
else
10048-
{
10049-
return CheckIfPrototypeChainContainsProxyObject(prototype->GetPrototype());
10043+
if (prototype->GetTypeId() == TypeIds_Proxy)
10044+
{
10045+
return true;
10046+
}
10047+
10048+
prototype = prototype->GetPrototype();
1005010049
}
10050+
10051+
return false;
1005110052
}
1005210053

1005310054
BOOL JavascriptOperators::Equal(Var aLeft, Var aRight, ScriptContext* scriptContext)

0 commit comments

Comments
 (0)