pig-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cheolsoo Park (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PIG-3160) GFCross uses unnecessary loop
Date Tue, 05 Feb 2013 20:23:13 GMT

    [ https://issues.apache.org/jira/browse/PIG-3160?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13571696#comment-13571696
] 

Cheolsoo Park commented on PIG-3160:
------------------------------------

+1.
{quote}
int arrays are initialized with all 0s already
{quote}
Indeed, this is true:
http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.12.5
                
> GFCross uses unnecessary loop
> -----------------------------
>
>                 Key: PIG-3160
>                 URL: https://issues.apache.org/jira/browse/PIG-3160
>             Project: Pig
>          Issue Type: Improvement
>          Components: internal-udfs
>    Affects Versions: 0.10.0
>            Reporter: Sandy Ryza
>         Attachments: PIG-3610.patch
>
>
> The GFCross UDF contains the following code:
> {code}
> int[] digits = new int[numInputs];
> for (int i=0; i<numInputs; i++){
>   if (i == myNumber){
>     digits[i] = r.nextInt(numGroupsPerInput);
>   }else{
>     digits[i] = 0;
>  }
> }
> {code}
> As int arrays are initialized with all 0s already, this is equivalent to just settings
digits[myNumber] and leaving the rest alone.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message