Skip to content

initialize owned slice with capacity to avoid reallocations#768

Open
ErikJiang wants to merge 1 commit intokubernetes-sigs:mainfrom
ErikJiang:init_owned_slice
Open

initialize owned slice with capacity to avoid reallocations#768
ErikJiang wants to merge 1 commit intokubernetes-sigs:mainfrom
ErikJiang:init_owned_slice

Conversation

@ErikJiang
Copy link
Member

What type of PR is this?

/kind cleanup

What this PR does / why we need it

Replace var owned []*appsv1.ControllerRevision with owned := make([]*appsv1.ControllerRevision, 0, len(history)) to pre-allocate capacity based on known size, reducing potential slice reallocations during appends.

Which issue(s) this PR fixes

Fixes #

Special notes for your reviewer

Does this PR introduce a user-facing change?


Signed-off-by: bo.jiang <bo.jiang@daocloud.io>
@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Mar 7, 2026
@netlify
Copy link

netlify bot commented Mar 7, 2026

Deploy Preview for kubernetes-sigs-lws canceled.

Name Link
🔨 Latest commit e81ae19
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-lws/deploys/69ac24a4db4fd70008b73295

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ErikJiang
Once this PR has been reviewed and has the lgtm label, please assign ahg-g for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants