Skip to content

Commit d455ac4

Browse files
author
Meghana Gupta
committed
[MERGE #5929 @meg-gupta] Add boolean fast path in ToBoolean
Merge pull request #5929 from pr/meg-gupta/boolfastpath
2 parents dd6f5ce + 1295526 commit d455ac4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/Runtime/Language/JavascriptConversion.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -769,9 +769,6 @@ using namespace Js;
769769
case TypeIds_Symbol:
770770
return true;
771771

772-
case TypeIds_Boolean:
773-
return UnsafeVarTo<JavascriptBoolean>(aValue)->GetValue();
774-
775772
#if !FLOATVAR
776773
case TypeIds_Number:
777774
{

lib/Runtime/Language/JavascriptConversion.inl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ namespace Js {
1515
inline BOOL JavascriptConversion::ToBoolean(Var aValue,ScriptContext* scriptContext)
1616
{
1717
JIT_HELPER_NOT_REENTRANT_HEADER(Conv_ToBoolean, reentrancylock, scriptContext->GetThreadContext());
18-
if (TaggedInt::Is(aValue))
18+
19+
if (VarIs<JavascriptBoolean>(aValue))
20+
{
21+
return UnsafeVarTo<JavascriptBoolean>(aValue)->GetValue();
22+
}
23+
else if (TaggedInt::Is(aValue))
1924
{
2025
return aValue != reinterpret_cast<Var>(AtomTag_IntPtr);
2126
}

0 commit comments

Comments
 (0)