Skip to content
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

vsr: make comptime checksum(&.{}) available everywhere #1334

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

matklad
Copy link
Member

@matklad matklad commented Nov 30, 2023

I have a bunch of asserts on the empty checksum in free set, and writing assert(checksum = vsr.checksum(&.{})) makes me hesitate, as that involves non-trivial runtime computation. So let's make

comptime vsr.checksum(&.{})

JustWork, so that's a no-brainer for the future.

test "checksum empty" {
var stream = ChecksumStream.init();
stream.add(&.{});
assert(stream.checksum() == comptime checksum(&.{}));
Copy link
Contributor

Choose a reason for hiding this comment

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

Use expectEqual here

@matklad matklad marked this pull request as ready for review November 30, 2023 14:50
@matklad
Copy link
Member Author

matklad commented Nov 30, 2023

I think this is an improvement as-is, I'll update free-set parts separately, when #1332 merges.

I have a bunch of asserts on the empty checksum in free set, and writing
`assert(checksum = vsr.checksum(&.{}))` makes me hesitate, as that
involves non-trivial runtime computation. So let's make

    comptime vsr.checksum(&.{})

JustWork, so that's a no-brainer for the future.
@matklad matklad added this pull request to the merge queue Dec 4, 2023
Merged via the queue into main with commit 7b70789 Dec 4, 2023
27 checks passed
@matklad matklad deleted the matklad/checksum-empty branch December 4, 2023 12:14
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.

None yet

2 participants