You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2018/12/13 10:10:00 UTC

[jira] [Commented] (GROOVY-8831) Add instance methods from `String` to `GString`

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

Paul King commented on GROOVY-8831:
-----------------------------------

Status? Is this complete or did we decide against this?

> Add instance methods from `String` to `GString` 
> ------------------------------------------------
>
>                 Key: GROOVY-8831
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8831
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Daniel Sun
>            Assignee: Daniel Sun
>            Priority: Major
>             Fix For: 3.0.0-alpha-4
>
>
> The reason why we add {{String}} instance methods is to improve performance to some extent and reduce the size of class file:
> {code:java}
> @groovy.transform.CompileStatic
> def y() {
>     "abc${'123'}def".toUpperCase()
> }
> {code}
> *Original:*
> {code:java}
>     NEW org/codehaus/groovy/runtime/GStringImpl
>     DUP
>     ICONST_1
>     ANEWARRAY java/lang/Object
>     DUP
>     ICONST_0
>     LDC "123"
>     AASTORE
>     ICONST_2
>     ANEWARRAY java/lang/String
>     DUP
>     ICONST_0
>     LDC "abc"
>     AASTORE
>     DUP
>     ICONST_1
>     LDC "def"
>     AASTORE
>     INVOKESPECIAL org/codehaus/groovy/runtime/GStringImpl.<init> ([Ljava/lang/Object;[Ljava/lang/String;)V
>     INVOKESTATIC org/codehaus/groovy/runtime/typehandling/ShortTypeHandling.castToString (Ljava/lang/Object;)Ljava/lang/String;
>     CHECKCAST java/lang/String
>     INVOKEVIRTUAL java/lang/String.toUpperCase ()Ljava/lang/String;
>     ARETURN
> {code}
> *After change:*
> {code:java}
>     NEW org/codehaus/groovy/runtime/GStringImpl
>     DUP
>     ICONST_1
>     ANEWARRAY java/lang/Object
>     DUP
>     ICONST_0
>     LDC "123"
>     AASTORE
>     ICONST_2
>     ANEWARRAY java/lang/String
>     DUP
>     ICONST_0
>     LDC "abc"
>     AASTORE
>     DUP
>     ICONST_1
>     LDC "def"
>     AASTORE
>     INVOKESPECIAL org/codehaus/groovy/runtime/GStringImpl.<init> ([Ljava/lang/Object;[Ljava/lang/String;)V
>     INVOKEVIRTUAL groovy/lang/GString.toUpperCase ()Ljava/lang/String;
>     ARETURN
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)