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 {...@@ -59,14 +59,14 @@ pub const CacheHash = struct {
59 };59 };
60 }60 }
6161
62 pub fn cache_buf(self: *@This(), val: []const u8) void {62 pub fn addSlice(self: *@This(), val: []const u8) void {
63 debug.assert(self.manifest_file == null);63 debug.assert(self.manifest_file == null);
6464
65 self.blake3.update(val);65 self.blake3.update(val);
66 self.blake3.update(&[_]u8{0});66 self.blake3.update(&[_]u8{0});
67 }67 }
6868
69 pub fn cache(self: *@This(), val: var) void {69 pub fn add(self: *@This(), val: var) void {
70 debug.assert(self.manifest_file == null);70 debug.assert(self.manifest_file == null);
7171
72 const val_type = @TypeOf(val);72 const val_type = @TypeOf(val);
...@@ -75,7 +75,7 @@ pub const CacheHash = struct {...@@ -75,7 +75,7 @@ pub const CacheHash = struct {
75 const buf_len = @divExact(int_info.bits, 8);75 const buf_len = @divExact(int_info.bits, 8);
76 var buf: [buf_len]u8 = undefined;76 var buf: [buf_len]u8 = undefined;
77 mem.writeIntNative(val_type, &buf, val);77 mem.writeIntNative(val_type, &buf, val);
78 self.cache_buf(&buf);78 self.addSlice(&buf);
79 } else {79 } else {
80 @compileError("Unsupported integer size. Please use a multiple of 8, manually convert to a u8 slice.");80 @compileError("Unsupported integer size. Please use a multiple of 8, manually convert to a u8 slice.");
81 },81 },
...@@ -94,7 +94,7 @@ pub const CacheHash = struct {...@@ -94,7 +94,7 @@ pub const CacheHash = struct {
94 var cache_hash_file = try self.files.addOne();94 var cache_hash_file = try self.files.addOne();
95 cache_hash_file.path = try fs.path.resolve(self.alloc, &[_][]const u8{file_path});95 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.?);
98 }98 }
9999
100 pub fn hit(self: *@This(), out_digest: *ArrayList(u8)) !bool {100 pub fn hit(self: *@This(), out_digest: *ArrayList(u8)) !bool {
...@@ -312,9 +312,9 @@ test "cache file and the recall it" {...@@ -312,9 +312,9 @@ test "cache file and the recall it" {
312 var ch = try CacheHash.init(testing.allocator, temp_manifest_dir);312 var ch = try CacheHash.init(testing.allocator, temp_manifest_dir);
313 defer ch.release();313 defer ch.release();
314314
315 ch.cache(true);315 ch.add(true);
316 ch.cache(@as(u16, 1234));316 ch.add(@as(u16, 1234));
317 ch.cache_buf("1234");317 ch.addSlice("1234");
318 try ch.cache_file("test.txt");318 try ch.cache_file("test.txt");
319319
320 // There should be nothing in the cache320 // There should be nothing in the cache
...@@ -326,9 +326,9 @@ test "cache file and the recall it" {...@@ -326,9 +326,9 @@ test "cache file and the recall it" {
326 var ch = try CacheHash.init(testing.allocator, temp_manifest_dir);326 var ch = try CacheHash.init(testing.allocator, temp_manifest_dir);
327 defer ch.release();327 defer ch.release();
328328
329 ch.cache(true);329 ch.add(true);
330 ch.cache(@as(u16, 1234));330 ch.add(@as(u16, 1234));
331 ch.cache_buf("1234");331 ch.addSlice("1234");
332 try ch.cache_file("test.txt");332 try ch.cache_file("test.txt");
333333
334 // Cache hit! We just "built" the same file334 // Cache hit! We just "built" the same file