[ 
https://issues.apache.org/jira/browse/GROOVY-10035?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Sun updated GROOVY-10035:
--------------------------------
    Description: 
The ticket is to provide some suggestion to tweak the fix of GROOVY-10034 ( 
[https://github.com/apache/groovy/pull/1556] ):

It seems that we could make the check simpler, we do not add extra checks but 
tweak the existing check.
h3. *Current*

[https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/classgen/asm/OperandStack.java#L334]
{code:java}
        if (targetType == top) return;
{code}
h3. *Proposed*

[https://github.com/apache/groovy/pull/1561]
{code:java}
if (ClassNodeUtils.isCompatibleWith(top, targetType)) return;
{code}

  was:
The ticket is to provide some suggestion to tweak the fix of GROOVY-10034

It seems that we could make the check simpler, we do not add extra checks but 
tweak the existing check:

[https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/classgen/asm/OperandStack.java#L342-L345]

{code:java}
        if (targetType.isArray() && 
targetType.getComponentType().equals(ClassHelper.OBJECT_TYPE)
                && top.isArray() && 
!ClassHelper.isPrimitiveType(top.getComponentType())) {
            return;
        }
{code}

tweaked as:

{code:java}
// https://github.com/apache/groovy/pull/1561
if (ClassNodeUtils.isCompatibleWith(top, targetType)) return;
{code}


> Eliminate redundant type cast
> -----------------------------
>
>                 Key: GROOVY-10035
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10035
>             Project: Groovy
>          Issue Type: Improvement
>          Components: bytecode
>            Reporter: Eric Milles
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The ticket is to provide some suggestion to tweak the fix of GROOVY-10034 ( 
> [https://github.com/apache/groovy/pull/1556] ):
> It seems that we could make the check simpler, we do not add extra checks but 
> tweak the existing check.
> h3. *Current*
> [https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/classgen/asm/OperandStack.java#L334]
> {code:java}
>         if (targetType == top) return;
> {code}
> h3. *Proposed*
> [https://github.com/apache/groovy/pull/1561]
> {code:java}
> if (ClassNodeUtils.isCompatibleWith(top, targetType)) return;
> {code}



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

Reply via email to