Skip to content

Conversation

@kolyshkin
Copy link
Contributor

No description provided.

@rhatdan
Copy link
Member

rhatdan commented Aug 3, 2024

LGTM

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

WDYT about make(…, 0, len(…)) + continuing to use append?

I think that achieves the primary optimization goal (not over-allocating, and not calling an allocation function in the loop) without giving up on safety WRT hypothetical future logic changes — at some performance cost, 2 conditional jumps per loop instead of one (sadly, per https://godbolt.org/z/Gbo98a74K , Go can optimize out the range check in [i], but not the capacity check in append).

@kolyshkin
Copy link
Contributor Author

WDYT about make(…, 0, len(…)) + continuing to use append?

I thought about that, but since we don't do any filtering inside the loop here I went another way.

Changed.

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Thanks!

@mtrmac mtrmac merged commit 7847869 into containers:main Aug 5, 2024
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.

3 participants