Changeset 201681 in webkit


Ignore:
Timestamp:
Jun 4, 2016 12:10:24 PM (8 years ago)
Author:
Chris Dumez
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):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r201679 r201681  
     12016-06-04  Chris Dumez  <cdumez@apple.com>
     2
     3        Avoid redundant isUndefined() check for parameters that are both optional and nullable in overloads
     4        https://bugs.webkit.org/show_bug.cgi?id=158380
     5
     6        Reviewed by Brady Eidson.
     7
     8        * bindings/scripts/CodeGeneratorJS.pm:
     9        (GenerateParametersCheckExpression):
     10        * bindings/scripts/test/JS/JSTestObj.cpp:
     11        (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter):
     12
    1132016-06-04  Brent Fulgham  <bfulgham@apple.com>
    214
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r201627 r201681  
    16861686        } elsif ($codeGenerator->GetArrayOrSequenceType($type) || $codeGenerator->IsTypedArrayType($type) || $codeGenerator->IsWrapperType($type)) {
    16871687            my $condition = "";
    1688             $condition .= "${value}.isUndefined() || " if $parameter->isOptional;
    1689 
    1690             # http://heycam.github.io/webidl/#es-nullable-type
    1691             $condition .= "${value}.isUndefinedOrNull() || " if $parameter->isNullable;
     1688
     1689            if ($parameter->isNullable) {
     1690                $condition .= "${value}.isUndefinedOrNull() || ";
     1691            } elsif ($parameter->isOptional) {
     1692                $condition .= "${value}.isUndefined() || ";
     1693            }
    16921694
    16931695            if ($codeGenerator->GetArrayOrSequenceType($type)) {
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r201627 r201681  
    54685468    JSValue arg0(state->argument(0));
    54695469    JSValue arg1(state->argument(1));
    5470     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())))))
     5470    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())))))
    54715471        return jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1(state);
    54725472    if ((argsCount == 1 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))) || (argsCount == 2 && (arg0.isUndefinedOrNull() || (arg0.isObject() && asObject(arg0)->inherits(JSTestObj::info())))))
Note: See TracChangeset for help on using the changeset viewer.