Bug 73651

Summary: [Refactoring] Use join(", ", @arguments) to build a method argument string in CodeGenerator*.pm
Product: WebKit Reporter: Kentaro Hara <haraken>
Component: Tools / TestsAssignee: Kentaro Hara <haraken>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, japhet, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
check if all builds succeed
none
Patch none

Description Kentaro Hara 2011-12-02 05:52:44 PST
The code in CodeGenerator*.pm to build a method argument string is really dirty and error-prone. It is building an argument string incrementally judging whether ", " is necessary or not, like this:

my $method = ... ? "func(" : "func(a";
if (...) {
    $method .= $method =~ /\($/ ? "b" : ", b";
}
$method .= ")";

Alternatively, we can refactor the code as follows:

my $funcName = "func";
my @arguments;
push(@arguments, "a") if (...);
push(@arguments, "b") if (...);
my $method = $funcName . "(" . join(", ", @arguments) . ")";
Comment 1 Kentaro Hara 2011-12-02 06:19:46 PST
Created attachment 117616 [details]
check if all builds succeed
Comment 2 Kentaro Hara 2011-12-02 17:46:50 PST
Created attachment 117719 [details]
Patch
Comment 3 WebKit Review Bot 2011-12-02 23:22:27 PST
Comment on attachment 117719 [details]
Patch

Clearing flags on attachment: 117719

Committed r101914: <http://trac.webkit.org/changeset/101914>
Comment 4 WebKit Review Bot 2011-12-02 23:22:31 PST
All reviewed patches have been landed.  Closing bug.