Skip to content

refactor(build): optimize allocations and add tests #2601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

Jguer
Copy link
Owner

@Jguer Jguer commented Apr 24, 2025

introduces performance optimizations and adds test coverage to the build package.

  • pre-allocated maps and slices in installer.go and pkg_archive.go to reduce memory allocations.
  • used strings.builder in errors.go for more efficient error string construction.
  • tests for the parsepackagelist function.

@Jguer Jguer requested a review from Copilot April 24, 2025 10:08
Copy link

@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

This pull request refactors parts of the build package to optimize memory allocations and improve error construction performance, while also adding test coverage for the parsePackageList function.

  • Optimized map and slice pre-allocation in installer.go and pkg_archive.go
  • Refactored error string construction in errors.go using strings.Builder
  • Added comprehensive tests for the parsePackageList function in pkg_archive_test.go

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
pkg/sync/build/pkg_archive_test.go Added various test cases covering different package list parsing scenarios
pkg/sync/build/pkg_archive.go Optimized the allocation of the pkgdests map by pre-sizing based on the line count
pkg/sync/build/installer.go Improved pre-allocation for maps and slices to reduce memory allocations
pkg/sync/build/errors.go Refactored error message generation from concatenation to use strings.Builder

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