Make JSObject::getMethod have fewer branches
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Feb 2016 22:41:26 +0000 (22:41 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Feb 2016 22:41:26 +0000 (22:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=154603

Reviewed by Mark Lam.

Writing code with fewer branches is almost always better.

* runtime/JSObject.cpp:
(JSC::JSObject::getMethod):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196999 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSObject.cpp

index 7b176d0..6b01585 100644 (file)
@@ -1,3 +1,15 @@
+2016-02-23  Saam barati  <sbarati@apple.com>
+
+        Make JSObject::getMethod have fewer branches
+        https://bugs.webkit.org/show_bug.cgi?id=154603
+
+        Reviewed by Mark Lam.
+
+        Writing code with fewer branches is almost always better.
+
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::getMethod):
+
 2016-02-23  Filip Pizlo  <fpizlo@apple.com>
 
         B3::Value doesn't self-destruct virtually enough (Causes many leaks in LowerDFGToB3::appendOSRExit)
index c24bf64..64a124f 100644 (file)
@@ -2947,10 +2947,10 @@ JSValue JSObject::getMethod(ExecState* exec, CallData& callData, CallType& callT
     if (exec->hadException())
         return jsUndefined();
 
-    if (method.isUndefined() || method.isNull())
-        return jsUndefined();
-
     if (!method.isCell()) {
+        if (method.isUndefinedOrNull())
+            return jsUndefined();
+
         throwVMTypeError(exec, errorMessage);
         return jsUndefined();
     }