Skip to content

Core: Pre-size row lists built from known-size collections - #17581

Open
uros-b wants to merge 1 commit into
apache:mainfrom
uros-b:core-presize-manifest-row-lists
Open

Core: Pre-size row lists built from known-size collections#17581
uros-b wants to merge 1 commit into
apache:mainfrom
uros-b:core-presize-manifest-row-lists

Conversation

@uros-b

@uros-b uros-b commented Aug 9, 2026

Copy link
Copy Markdown
Member

Two lists are allocated with the default ArrayList capacity and then filled with exactly one element per iteration of a loop whose bound is already known, so they resize as they grow. This pre-sizes both:

  • ManifestsTable#partitionSummariesToRows — one row per entry in summaries
  • ManifestFiles — one pair per entry in groups

Lists.newArrayListWithCapacity is already used elsewhere in the module. Behavior-preserving.

Use Lists.newArrayListWithCapacity in ManifestsTable.partitionSummariesToRows and ManifestFiles to avoid intermediate ArrayList resizes when the target size is already known.
@github-actions github-actions Bot added the core label Aug 9, 2026

@ebyhr ebyhr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but there are still same patterns in other places.

@uros-b uros-b left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ebyhr. Yeah, probably there are other places too, but I happened to come across this one. Otherwise, the PR could explode quite a bit (like this one for example: #17534).

@anoopj anoopj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ebyhr

ebyhr commented Aug 10, 2026

Copy link
Copy Markdown
Member

Limiting the scope is perfectly acceptable, but I recommend providing an explanation of the intention in the PR description. This way, it becomes clear whether the limitation was intentional or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants