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

Daniel Sun commented on GROOVY-9637:
------------------------------------

If we return a copy of the array of strings/values, users can not change them 
as follows:
{code:java}
    public Object[] getValues() {
        return values.clone();
    }
{code}

{code:groovy}
def x = 42G
def y = "Answer is $x"
y.strings[0] = '6 x 7 = '
y.values[0] = 'the question'
{code}



As to {{toString}} behavior changed by MOP, it is hard to make the constructed 
string literal constant unless STC is enabled.



> Improve the performance of GString
> ----------------------------------
>
>                 Key: GROOVY-9637
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9637
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Daniel Sun
>            Priority: Major
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> {{GString}} will runĀ {{toString()}} whenever its literal string is needed, 
> e.g. methods like {{equals}}, {{hashCode}} are called, but unfortunately its 
> literal string will be re-constructed for each time and the process costs 
> quite a little of time.
> So I propose to check whether {{GString}} values are all of immutable type, 
> e.g. primitive types and their boxed type, {{String}}, etc. If yes,  use the 
> cached string literal, otherwise re-construct the literal string.



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

Reply via email to