[
https://issues.apache.org/jira/browse/GROOVY-11309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17815560#comment-17815560
]
ASF GitHub Bot commented on GROOVY-11309:
-----------------------------------------
paulk-asert commented on PR #2054:
URL: https://github.com/apache/groovy/pull/2054#issuecomment-1933522752
This looks okay to me. But, by way of background, if we ever wanted to
change the default list in Groovy from ArrayList to LinkedList (not that we
would), we would now have one more place to make a change. So, if we thought
such changes might be on the cards, this would increase the maintenance burden.
But I think we are okay here.
> Optimise bytecode for empty list expressions
> --------------------------------------------
>
> Key: GROOVY-11309
> URL: https://issues.apache.org/jira/browse/GROOVY-11309
> Project: Groovy
> Issue Type: Improvement
> Components: class generator, Compiler, performance
> Affects Versions: 2.5.23, 3.0.20, 4.0.18, 5.0.0-alpha-5
> Reporter: Oscar N
> Priority: Minor
>
> I have the following code:
> {code:groovy}
> class Book {
> String title
> String blurb = ''
> List<String> authors = []
> }
> {code}
> When checking the compiled output, the creation of the empty list goes
> through ScriptBytecodeAdapter:
> {code:java}
> @Generated
> public Book() {
> String var1 = "";
> this.blurb = var1;
> List var2 = ScriptBytecodeAdapter.createList(new Object[0]);
> this.authors = var2;
> MetaClass var3 = this.$getStaticMetaClass();
> this.metaClass = var3;
> }
> {code}
> This case can be simplified to "List var2 = new ArrayList()", which would
> avoid some overhead and slightly improve @POJO support.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)