authorgravatar for leroycepearson@geemili.xyzLeRoyce Pearson <leroycepearson@geemili.xyz> 2020-03-06 21:25:22-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-25 13:48:43-04:00
log4173dbdce907e39f376a08ce2f192655fc62b664
treebc0ef22de204e3d6ed83f4864b99dacb44dbd463
parent27bf1f781b5246914ba2fbdf556dbf72bc926b17

Rename `cache` functions to `add`


1 files changed, 10 insertions(+), 10 deletions(-)

lib/std/cache_hash.zig+10-10
......@@ -59,14 +59,14 @@ pub const CacheHash = struct {
5959 };
6060 }
6161
62 pub fn cache_buf(self: *@This(), val: []const u8) void {
62 pub fn addSlice(self: *@This(), val: []const u8) void {
6363 debug.assert(self.manifest_file == null);
6464
6565 self.blake3.update(val);
6666 self.blake3.update(&[_]u8{0});
6767 }
6868
69 pub fn cache(self: *@This(), val: var) void {
69 pub fn add(self: *@This(), val: var) void {
7070 debug.assert(self.manifest_file == null);
7171
7272 const val_type = @TypeOf(val);
......@@ -75,7 +75,7 @@ pub const CacheHash = struct {
7575 const buf_len = @divExact(int_info.bits, 8);
7676 var buf: [buf_len]u8 = undefined;
7777 mem.writeIntNative(val_type, &buf, val);
78 self.cache_buf(&buf);
78 self.addSlice(&buf);
7979 } else {
8080 @compileError("Unsupported integer size. Please use a multiple of 8, manually convert to a u8 slice.");
8181 },
......@@ -94,7 +94,7 @@ pub const CacheHash = struct {
9494 var cache_hash_file = try self.files.addOne();
9595 cache_hash_file.path = try fs.path.resolve(self.alloc, &[_][]const u8{file_path});
9696
97 self.cache_buf(cache_hash_file.path.?);
97 self.addSlice(cache_hash_file.path.?);
9898 }
9999
100100 pub fn hit(self: *@This(), out_digest: *ArrayList(u8)) !bool {
......@@ -312,9 +312,9 @@ test "cache file and the recall it" {
312312 var ch = try CacheHash.init(testing.allocator, temp_manifest_dir);
313313 defer ch.release();
314314
315 ch.cache(true);
316 ch.cache(@as(u16, 1234));
317 ch.cache_buf("1234");
315 ch.add(true);
316 ch.add(@as(u16, 1234));
317 ch.addSlice("1234");
318318 try ch.cache_file("test.txt");
319319
320320 // There should be nothing in the cache
......@@ -326,9 +326,9 @@ test "cache file and the recall it" {
326326 var ch = try CacheHash.init(testing.allocator, temp_manifest_dir);
327327 defer ch.release();
328328
329 ch.cache(true);
330 ch.cache(@as(u16, 1234));
331 ch.cache_buf("1234");
329 ch.add(true);
330 ch.add(@as(u16, 1234));
331 ch.addSlice("1234");
332332 try ch.cache_file("test.txt");
333333
334334 // Cache hit! We just "built" the same file