Skip to content

Less slice construction/copying thanks to generics#2584

Merged
bufdev merged 2 commits intomainfrom
jh/generic-so-less-descriptor-slice-copy
Nov 14, 2023
Merged

Less slice construction/copying thanks to generics#2584
bufdev merged 2 commits intomainfrom
jh/generic-so-less-descriptor-slice-copy

Conversation

@jhump
Copy link
Member

@jhump jhump commented Nov 13, 2023

Instead of converting a []bufimage.ImageFile or []*imagev1.ImageFile first to a []protodescriptor.FileDescriptor and then to a []*descriptorpb.FileDescriptorProto, we can easily elide the first step using generics.

So instead of "generic" functions accepting a []protodescriptor.FileDescriptor, they use type arguments, so they accept any []F where F implements protodescriptor.FileDescriptor.

This allowed for removal of a few no-longer-needed helper functions.

@jhump jhump requested a review from bufdev November 13, 2023 21:21
@bufdev
Copy link
Member

bufdev commented Nov 13, 2023

Can you fix merge conflicts, and also locally check that this branch cleanly merges into the bufmod branch (but do not push to the bufmod branch)?

@jhump
Copy link
Member Author

jhump commented Nov 13, 2023

@bufdev, done. You can see the results of clean merge to bufmod here: https://github.com/bufbuild/buf/commits/jh/pr-2854+bufmod
(CI is red, but it was red on bufmod branch, too, before I tried merging.)

@bufdev bufdev merged commit 82103ef into main Nov 14, 2023
@bufdev bufdev deleted the jh/generic-so-less-descriptor-slice-copy branch November 14, 2023 03:19
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.

2 participants