Skip to content

Optimize r2-bucket Checksums#2201

Merged
jasnell merged 1 commit intomainfrom
jsnell/optimize-r2bucket-checksums
May 31, 2024
Merged

Optimize r2-bucket Checksums#2201
jasnell merged 1 commit intomainfrom
jsnell/optimize-r2bucket-checksums

Conversation

@jasnell
Copy link
Collaborator

@jasnell jasnell commented May 31, 2024

This is a bit of a random drive-by optimization. I noticed that the R2Bucket Checksums class was unnecessarily performing multiple heap allocations and copies when it could be implemented with stack allocation and a single copy. This does end up making instances of Checksum slightly larger but reduces the number of small heap allocations and copies.

In reality, the Checksums class really could have been a struct given how it is used but that would possibly be a breaking change :-/

@jasnell jasnell requested review from jp4a50 and mikea May 31, 2024 05:04
@jasnell jasnell requested review from a team as code owners May 31, 2024 05:04
This is a bit of a random drive-by optimization. I noticed that the
R2Bucket `Checksums` class was unnecessarily performing multiple
heap allocations and copies when it could be implemented with stack
allocation and a single copy.

In reality, the `Checksums` class really could have been a struct
given how it is used but that would possibly be a breaking change :-/
@jasnell jasnell force-pushed the jsnell/optimize-r2bucket-checksums branch from fd8dfd4 to 0607352 Compare May 31, 2024 18:56
@jasnell jasnell merged commit 20d3c00 into main May 31, 2024
@jasnell jasnell deleted the jsnell/optimize-r2bucket-checksums branch May 31, 2024 20:51
jasnell added a commit that referenced this pull request Jun 6, 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.

2 participants