Skip to content

Commit ff04bb3

Browse files
committed
fix: style
1 parent c968469 commit ff04bb3

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

build.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ pub fn build(b: *std.Build) !void {
3535
});
3636
docs_step.dependOn(&docs_install.step);
3737

38-
// Benchmarks
39-
const benchs_step = b.step("bench", "Run benchmarks");
38+
// Benchmark
39+
const bench_step = b.step("bench", "Run benchmark");
4040

41-
const benchs = b.addExecutable(.{
41+
const bench_exe = b.addExecutable(.{
4242
.name = "bench",
4343
.version = version,
4444
.root_module = b.createModule(.{
@@ -48,11 +48,11 @@ pub fn build(b: *std.Build) !void {
4848
}),
4949
});
5050

51-
const benchs_run = b.addRunArtifact(benchs);
51+
const bench_exe_run = b.addRunArtifact(bench_exe);
5252
if (b.args) |args| {
53-
benchs_run.addArgs(args);
53+
bench_exe_run.addArgs(args);
5454
}
55-
benchs_step.dependOn(&benchs_run.step);
55+
bench_step.dependOn(&bench_exe_run.step);
5656

5757
// Test suite
5858
const tests_step = b.step("test", "Run test suite");

src/bench.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn benchmarkSequence(gpa: std.mem.Allocator, writer: anytype) !void {
5454
num = i % 100;
5555
node = try gpa.create(Cache.Node);
5656
node.* = .{ .key = num, .value = num };
57-
_ = try cache.put(node);
57+
_ = cache.put(node);
5858
}
5959

6060
while (i < NUM_ITERS) : (i += 1) {
@@ -80,7 +80,7 @@ fn benchmarkComposite(gpa: std.mem.Allocator, random: std.Random, writer: anytyp
8080
num = random.uintLessThan(u64, 100);
8181
node = try gpa.create(Cache.Node);
8282
node.* = .{ .key = num, .value = .{ @splat(0), num } };
83-
_ = try cache.put(node);
83+
_ = cache.put(node);
8484
}
8585

8686
while (i < NUM_ITERS) : (i += 1) {
@@ -107,7 +107,7 @@ fn benchmarkCompositeNormal(gpa: std.mem.Allocator, random: std.Random, writer:
107107
num %= 100;
108108
node = try gpa.create(Cache.Node);
109109
node.* = .{ .key = num, .value = .{ @splat(0), num } };
110-
_ = try cache.put(node);
110+
_ = cache.put(node);
111111
}
112112

113113
while (i < NUM_ITERS) : (i += 1) {

src/sieve.zig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn Cache(comptime K: type, comptime V: type) type {
2222
};
2323

2424
/// Initialize cache with given capacity.
25-
pub fn init(allocator: std.mem.Allocator, capacity: u32) !Self {
25+
pub fn init(allocator: std.mem.Allocator, capacity: u32) std.mem.Allocator.Error!Self {
2626
var self: Self = .{};
2727
try self.map.ensureTotalCapacity(allocator, capacity);
2828
return self;
@@ -53,7 +53,7 @@ pub fn Cache(comptime K: type, comptime V: type) type {
5353

5454
/// Put node pointer and return `true` if associated key is not already present.
5555
/// Otherwise, put node pointer, evicting old entry, and return `false`.
56-
pub fn put(self: *Self, node: *Node) !bool {
56+
pub fn put(self: *Self, node: *Node) bool {
5757
if (self.map.getPtr(node.key)) |old_node| {
5858
node.is_visited = true;
5959
old_node.* = node;
@@ -132,13 +132,13 @@ test Cache {
132132
var flipflop_node: StringCache.Node = .{ .key = "flip", .value = "flop" };
133133
var ticktock_node: StringCache.Node = .{ .key = "tick", .value = "tock" };
134134

135-
try std.testing.expect(try cache.put(&zigzag_node));
136-
try std.testing.expect(try cache.put(&foobar_node));
135+
try std.testing.expect(cache.put(&zigzag_node));
136+
try std.testing.expect(cache.put(&foobar_node));
137137

138138
try std.testing.expectEqualStrings("bar", cache.fetchRemove("foo").?);
139139

140-
try std.testing.expect(try cache.put(&flipflop_node));
141-
try std.testing.expect(try cache.put(&ticktock_node));
140+
try std.testing.expect(cache.put(&flipflop_node));
141+
try std.testing.expect(cache.put(&ticktock_node));
142142

143143
try std.testing.expectEqualStrings("zag", cache.get("zig").?);
144144
try std.testing.expectEqual(cache.get("foo"), null);
@@ -156,10 +156,10 @@ test Cache {
156156
var foobar_node: StringCache.Node = .{ .key = "foo", .value = "bar" };
157157
var flipflop_node: StringCache.Node = .{ .key = "flip", .value = "flop" };
158158

159-
try std.testing.expect(try cache.put(&zigzag_node));
160-
try std.testing.expect(try cache.put(&foobar_node));
161-
try std.testing.expect(!try cache.put(&zigupd_node));
162-
try std.testing.expect(try cache.put(&flipflop_node));
159+
try std.testing.expect(cache.put(&zigzag_node));
160+
try std.testing.expect(cache.put(&foobar_node));
161+
try std.testing.expect(!cache.put(&zigupd_node));
162+
try std.testing.expect(cache.put(&flipflop_node));
163163

164164
try std.testing.expectEqualStrings("upd", cache.get("zig").?);
165165
}

0 commit comments

Comments
 (0)