Title: [201681] trunk/Source/WebCore
Revision
201681
Author
[email protected]
Date
2016-06-04 12:10:24 -0700 (Sat, 04 Jun 2016)

Log Message

Avoid redundant isUndefined() check for parameters that are both optional and nullable in overloads
https://bugs.webkit.org/show_bug.cgi?id=158380

Reviewed by Brady Eidson.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateParametersCheckExpression):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (201680 => 201681)


--- trunk/Source/WebCore/ChangeLog	2016-06-04 18:58:08 UTC (rev 201680)
+++ trunk/Source/WebCore/ChangeLog	2016-06-04 19:10:24 UTC (rev 201681)
@@ -1,3 +1,15 @@
+2016-06-04  Chris Dumez  <[email protected]>
+
+        Avoid redundant isUndefined() check for parameters that are both optional and nullable in overloads
+        https://bugs.webkit.org/show_bug.cgi?id=158380
+
+        Reviewed by Brady Eidson.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateParametersCheckExpression):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter):
+
 2016-06-04  Brent Fulgham  <[email protected]>
 
         CSP: Content Security Policy directive, upgrade-insecure-requests (UIR)

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (201680 => 201681)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-06-04 18:58:08 UTC (rev 201680)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-06-04 19:10:24 UTC (rev 201681)
@@ -1685,10 +1685,12 @@
             $usedArguments{$parameterIndex} = 1;
         } elsif ($codeGenerator->GetArrayOrSequenceType($type) || $codeGenerator->IsTypedArrayType($type) || $codeGenerator->IsWrapperType($type)) {
             my $condition = "";
-            $condition .= "${value}.isUndefined() || " if $parameter->isOptional;
 
-            # http://heycam.github.io/webidl/#es-nullable-type
-            $condition .= "${value}.isUndefinedOrNull() || " if $parameter->isNullable;
+            if ($parameter->isNullable) {
+                $condition .= "${value}.isUndefinedOrNull() || ";
+            } elsif ($parameter->isOptional) {
+                $condition .= "${value}.isUndefined() || ";
+            }
 
             if ($codeGenerator->GetArrayOrSequenceType($type)) {
                 # FIXME: Add proper support for T[], T[]?, sequence<T>.

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (201680 => 201681)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-06-04 18:58:08 UTC (rev 201680)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-06-04 19:10:24 UTC (rev 201681)
@@ -5467,7 +5467,7 @@
     size_t argsCount = std::min<size_t>(2, state->argumentCount());
     JSValue arg0(state->argument(0));
     JSValue arg1(state->argument(1));
-    if ((argsCount == 1 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))) || (argsCount == 2 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info()))) && (arg1.isUndefined() || arg1.isUndefinedOrNull() || (arg1.isObject() && asObject(arg1)->inherits(JSTestObj::info())))))
+    if ((argsCount == 1 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))) || (argsCount == 2 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info()))) && (arg1.isUndefinedOrNull() || (arg1.isObject() && asObject(arg1)->inherits(JSTestObj::info())))))
         return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1(state);
     if ((argsCount == 1 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))) || (argsCount == 2 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))))
         return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2(state);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to