[
https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12574429#action_12574429
]
Benjamin Francisoud commented on PIG-106:
-----------------------------------------
I was up-to-date with the latest svn rev when I did the patch, I'm sorry you
got errors :(
I will take a look at the if/else you are mentioning... if I did that that was
be mistake.
Few cases where I add to modify code:
When there was this kind of code:
{code:java}
if (boolean)
something("a" + "b" + "c");
else
else("a" + "b" + "c");
{code}
I had to put brackets when using the StringBuilder
{code:java}
if (boolean) {
StringBuilder sb = new StringBuilder();
sb.append("a");
sb.append("b");
sb.append("c");
something(sb.toString());
} else {
StringBuilder sb = new StringBuilder();
sb.append("a");
sb.append("b");
sb.append("c");
else(sb.toString());
}
{code}
Other case:
{code:java}
log.debug("a" + "b" + "c");
{code}
replaced with
{code:java}
if (log.isDebugEnable()) {
StringBuilder sb = new StringBuilder();
sb.append("a");
sb.append("b");
sb.append("c");
log.debug(sb.toString());
}
{code}
> Optimize Pig by replacing String '+' and StringBuffer with StringBuilder
> ------------------------------------------------------------------------
>
> Key: PIG-106
> URL: https://issues.apache.org/jira/browse/PIG-106
> Project: Pig
> Issue Type: Improvement
> Components: impl
> Affects Versions: 0.1.0
> Reporter: Benjamin Francisoud
> Assignee: Benjamin Francisoud
> Attachments: PIG-106-v01.patch, PIG-106-v02.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
> for (int j = 0; j < LOOP_COUNT; j++) {
> sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
> }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s)
> reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
> for (int j = 0; j < LOOP_COUNT; j++) {
> sb.append(i);
> sb.append("\t");
> sb.append(i);
> sb.append("\t");
> sb.append(j % 2);
> sb.append("\n");
> }
> }
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.