Skip to content

Conversation

samchmou
Copy link

  • Use struct{} instead of bool in the map to reduce memory usage.
  • Combine declaration and initialization of the result slice.
  • Initialize result slice with a capacity equal to the input slice length to reduce allocations.

These changes improve memory efficiency and make the code more concise.

Changes

Submitter Checklist

  • 📝 Ensure your commit message is clear and informative. Refer to the How to write a git commit message guide. Include the commit message in the PR body rather than linking to an external site (e.g., Jira ticket).

  • ♽ Run make test lint before submitting a PR to avoid unnecessary CI processing. Consider installing pre-commit and running pre-commit install in the repository root for an efficient workflow.

  • ✨ We use linters to maintain clean and consistent code. Run make lint before submitting a PR. Some linters offer a --fix mode, executable with make fix-linters (ensure markdownlint and golangci-lint are installed).

  • 📖 Document any user-facing features or changes in behavior.

  • 🧪 While 100% coverage isn't required, we encourage unit tests for code changes where possible.

  • 🎁 If feasible, add an end-to-end test. See README for details.

  • 🔎 Address any CI test flakiness before merging, or provide a valid reason to bypass it (e.g., token rate limitations).

  • If adding a provider feature, fill in the following details:

Git Provider Supported
GitHub App ✅️
GitHub Webhook ❌️
Gitea ❌️
GitLab ❌️
Bitbucket Cloud ❌️
Bitbucket Data Center ❌️

(update the documentation accordingly)

- Use struct{} instead of bool in the map to reduce memory usage.
- Combine declaration and initialization of the result slice.
- Initialize result slice with a capacity equal to the input slice
  length to reduce allocations.

These changes improve memory efficiency and make the code more concise.

Signed-off-by: Chmouel Boudjnah <chmouel@chmouel.com>
@chmouel
Copy link
Member

chmouel commented Mar 20, 2025

/ok-to-test

@chmouel chmouel requested a review from Copilot March 20, 2025 12:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

A pull request to optimize the removeDuplicates function by reducing memory usage and improving code conciseness.

  • Use struct{} instead of bool in the map
  • Combine the declaration and initialization of the result slice with a preallocated capacity

@chmouel
Copy link
Member

chmouel commented Mar 20, 2025

/merge

@pipelines-as-code pipelines-as-code bot merged commit 50f58bf into openshift-pipelines:main Mar 20, 2025
5 checks passed
Copy link

✅ PR Successfully Merged

  • Merge method: rebase
  • Merged by: @chmouel
  • Total approvals: 1/1

Approvals Summary:

Reviewer Permission Status
@chmouel admin

Thank you @samchmou for your valuable contribution! 🎉

Automated by the PAC Boussole 🧭

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants