Bug 73651 - [Refactoring] Use join(", ", @arguments) to build a method argument string in CodeGenerator*.pm
Summary: [Refactoring] Use join(", ", @arguments) to build a method argument string in...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kentaro Hara
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-02 05:52 PST by Kentaro Hara
Modified: 2011-12-02 23:22 PST (History)
3 users (show)

See Also:


Attachments
check if all builds succeed (30.95 KB, patch)
2011-12-02 06:19 PST, Kentaro Hara
no flags Details | Formatted Diff | Diff
Patch (30.95 KB, patch)
2011-12-02 17:46 PST, Kentaro Hara
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.