Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions s2s.zig
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn serializeRecursive(stream: anytype, comptime T: type, value: T) @TypeOf(strea
.ErrorSet => {
// Error unions are serialized by "index of sorted name", so we
// hash all names in the right order
const names = getSortedErrorNames(T);
const names = comptime getSortedErrorNames(T);

const index = for (names, 0..) |name, i| {
if (std.mem.eql(u8, name, @errorName(value)))
Expand Down Expand Up @@ -485,13 +485,13 @@ fn getSortedErrorNames(comptime T: type) []const []const u8 {
sorted_names[i] = err.name;
}

std.sort.sort([]const u8, &sorted_names, {}, struct {
std.sort.sort([]const u8, &sorted_names, {}, struct {
fn order(ctx: void, lhs: []const u8, rhs: []const u8) bool {
_ = ctx;
return (std.mem.order(u8, lhs, rhs) == .lt);
}
}.order);
return &sorted_names;
return &sorted_names;
}
}

Expand Down Expand Up @@ -580,7 +580,7 @@ fn computeTypeHashInternal(hasher: *TypeHashFn, comptime T: type) void {
// hash all names in the right order

hasher.update("error set");
const names = getSortedErrorNames(T);
const names = comptime getSortedErrorNames(T);
for (names) |name| {
hasher.update(name);
}
Expand Down