Skip to content

⚡ Optimize collection to array conversion#368

Merged
keeganwitt merged 1 commit intogroovy:masterfrom
keeganwitt:performance-optimization-to-array-size-3914199496113272662
Mar 24, 2026
Merged

⚡ Optimize collection to array conversion#368
keeganwitt merged 1 commit intogroovy:masterfrom
keeganwitt:performance-optimization-to-array-size-3914199496113272662

Conversation

@keeganwitt
Copy link
Copy Markdown
Member

  • Update ClassWrangler.java to use correctly sized array in toArray() and pre-size ArrayList.
  • Update ConsoleMojo.java, AbstractGroovySourcesMojo.java, and GroovyCompiler.java to use correctly sized array in toArray().

This avoids unnecessary zero-length array allocation and internal reflection-based resizing, improving performance in the Java 8 environment.

- Update `ClassWrangler.java` to use correctly sized array in `toArray()` and pre-size `ArrayList`.
- Update `ConsoleMojo.java`, `AbstractGroovySourcesMojo.java`, and `GroovyCompiler.java` to use correctly sized array in `toArray()`.

This avoids unnecessary zero-length array allocation and internal reflection-based resizing, improving performance in the Java 8 environment.

Co-authored-by: keeganwitt <64612+keeganwitt@users.noreply.github.com>
@keeganwitt keeganwitt marked this pull request as ready for review March 24, 2026 04:33
@keeganwitt keeganwitt merged commit e1d66bb into groovy:master Mar 24, 2026
5 checks passed
@keeganwitt keeganwitt deleted the performance-optimization-to-array-size-3914199496113272662 branch March 24, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant