Skip to content

avoid unnecessary copy in cache code path#11348

Merged
tdyas merged 1 commit into
pantsbuild:masterfrom
tdyas:remove_introduced_copy
Dec 20, 2020
Merged

avoid unnecessary copy in cache code path#11348
tdyas merged 1 commit into
pantsbuild:masterfrom
tdyas:remove_introduced_copy

Conversation

@tdyas
Copy link
Copy Markdown
Contributor

@tdyas tdyas commented Dec 19, 2020

[ci skip-build-wheels]

Problem

#11344 introduced a .to_bytes() helper for protobuf messages. However, in one spot, this introduced a unnecessary copy because the result is converted to a Vec<u8> immediately.

Solution

Remove the unnecessary copy by encoding into a Vec<u8> directly.

It might be possible to switch the PlatformAndResponseBytes struct to use Bytes instead of Vec<u8> but that would require reasoning about whether it would change the format of the struct when stored in the cache, which I want to avoid having to do for now.

Result

Existing tests pass.

@tdyas tdyas merged commit 9a8e1f3 into pantsbuild:master Dec 20, 2020
@tdyas tdyas deleted the remove_introduced_copy branch December 20, 2020 00:34
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