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

Juan Pablo Santos Rodríguez commented on JSPWIKI-1153:
------------------------------------------------------

I've got to take a closer look at the PR, but seems that in this case inlined 
variables are either constructed and returned
{code:java}
final VariableInfo[] var = { new VariableInfo( data.getAttributeString("id"), 
                                               
"org.apache.wiki.ui.admin.AdminBean",
                                               true,
                                               VariableInfo.NESTED )
};
return var;
{code}
vs
{code:java}
return new VariableInfo[] { new VariableInfo( data.getAttributeString("id"),
                                              
"org.apache.wiki.ui.admin.AdminBean",
                                              true,
                                              VariableInfo.NESTED )
};
{code}
or objects holding references to existing objects
{code}
for ( String s : ... ) {
    String f = s;
    ...
}
{code}

or objects built from simple calls to other objects and then returned
{code}
final Method m = clazz.getDeclaredMethod( name, parm != null ? params : 
emptyparms );
return m;
{code}

I think that inlining makes sense in those cases, as the code is easier to 
follow; however, if there were any cases such as 
{code}
x =  veryComplexMethod()
return x;
{code}
I'd be +1 on not inlining it, but let's take a proper look at the PR

> Inline Variable
> ---------------
>
>                 Key: JSPWIKI-1153
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-1153
>             Project: JSPWiki
>          Issue Type: Improvement
>            Reporter: Arturo Bernal
>            Priority: Minor
>              Labels: pull-request-available
>
> Remove unnecessary local variables that are immediately returned or are 
> immediately assigned to another variable and then not used.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to