diff options
| author | LeRoyce Pearson <leroycepearson@geemili.xyz> | 2020-03-06 21:25:22 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-05-25 13:48:43 -0400 |
| commit | 4173dbdce907e39f376a08ce2f192655fc62b664 (patch) | |
| tree | bc0ef22de204e3d6ed83f4864b99dacb44dbd463 /lib | |
| parent | 27bf1f781b5246914ba2fbdf556dbf72bc926b17 (diff) | |
| download | zig-4173dbdce907e39f376a08ce2f192655fc62b664.tar.gz zig-4173dbdce907e39f376a08ce2f192655fc62b664.zip | |
Rename `cache` functions to `add`
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/cache_hash.zig | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/std/cache_hash.zig b/lib/std/cache_hash.zig index 7ec642d348..1324a7ce79 100644 --- a/lib/std/cache_hash.zig +++ b/lib/std/cache_hash.zig @@ -59,14 +59,14 @@ pub const CacheHash = struct { }; } - pub fn cache_buf(self: *@This(), val: []const u8) void { + pub fn addSlice(self: *@This(), val: []const u8) void { debug.assert(self.manifest_file == null); self.blake3.update(val); self.blake3.update(&[_]u8{0}); } - pub fn cache(self: *@This(), val: var) void { + pub fn add(self: *@This(), val: var) void { debug.assert(self.manifest_file == null); const val_type = @TypeOf(val); @@ -75,7 +75,7 @@ pub const CacheHash = struct { const buf_len = @divExact(int_info.bits, 8); var buf: [buf_len]u8 = undefined; mem.writeIntNative(val_type, &buf, val); - self.cache_buf(&buf); + self.addSlice(&buf); } else { @compileError("Unsupported integer size. Please use a multiple of 8, manually convert to a u8 slice."); }, @@ -94,7 +94,7 @@ pub const CacheHash = struct { var cache_hash_file = try self.files.addOne(); cache_hash_file.path = try fs.path.resolve(self.alloc, &[_][]const u8{file_path}); - self.cache_buf(cache_hash_file.path.?); + self.addSlice(cache_hash_file.path.?); } pub fn hit(self: *@This(), out_digest: *ArrayList(u8)) !bool { @@ -312,9 +312,9 @@ test "cache file and the recall it" { var ch = try CacheHash.init(testing.allocator, temp_manifest_dir); defer ch.release(); - ch.cache(true); - ch.cache(@as(u16, 1234)); - ch.cache_buf("1234"); + ch.add(true); + ch.add(@as(u16, 1234)); + ch.addSlice("1234"); try ch.cache_file("test.txt"); // There should be nothing in the cache @@ -326,9 +326,9 @@ test "cache file and the recall it" { var ch = try CacheHash.init(testing.allocator, temp_manifest_dir); defer ch.release(); - ch.cache(true); - ch.cache(@as(u16, 1234)); - ch.cache_buf("1234"); + ch.add(true); + ch.add(@as(u16, 1234)); + ch.addSlice("1234"); try ch.cache_file("test.txt"); // Cache hit! We just "built" the same file |
