authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-30 21:21:22-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-30 21:24:41-07:00
logeeadd55d15852b6bc67b459b452e83a8a8ba2933
treed7fc29c3f7bcf7a7b5dd687b2502437bed312eab
parent1bb30c5e228f4a5ebc42cc23e593ebad3bd6dbbe

fix tools/process_headers.zig regression

When upgrading to the new std lib HashMap API, the process_headers code regressed because something that was supposed to be a pointer ended up being a copy of a value. This resulted in the modification of a field not being picked up. Also switch from Sha256 to Blake3 while we're at it.

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

tools/process_headers.zig+6-6
......@@ -15,7 +15,7 @@ const Arch = std.Target.Cpu.Arch;
1515const Abi = std.Target.Abi;
1616const OsTag = std.Target.Os.Tag;
1717const assert = std.debug.assert;
18const Sha256 = std.crypto.hash.sha2.Sha256;
18const Blake3 = std.crypto.hash.Blake3;
1919
2020const LibCTarget = struct {
2121 name: []const u8,
......@@ -314,7 +314,7 @@ pub fn main() !void {
314314 var max_bytes_saved: usize = 0;
315315 var total_bytes: usize = 0;
316316
317 var hasher = Sha256.init(.{});
317 var hasher = Blake3.init(.{});
318318
319319 for (libc_targets) |libc_target| {
320320 const dest_target = DestTarget{
......@@ -360,7 +360,7 @@ pub fn main() !void {
360360 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
361361 total_bytes += raw_bytes.len;
362362 const hash = try allocator.alloc(u8, 32);
363 hasher = Sha256.init(.{});
363 hasher = Blake3.init(.{});
364364 hasher.update(rel_path);
365365 hasher.update(trimmed);
366366 hasher.final(hash);
......@@ -412,12 +412,12 @@ pub fn main() !void {
412412 {
413413 var hash_it = path_kv.value.iterator();
414414 while (hash_it.next()) |hash_kv| {
415 const contents = &hash_to_contents.get(hash_kv.value).?;
415 const contents = &hash_to_contents.getEntry(hash_kv.value).?.value;
416416 try contents_list.append(contents);
417417 }
418418 }
419419 std.sort.sort(*Contents, contents_list.span(), {}, Contents.hitCountLessThan);
420 var best_contents = contents_list.popOrNull().?;
420 const best_contents = contents_list.popOrNull().?;
421421 if (best_contents.hit_count > 1) {
422422 // worth it to make it generic
423423 const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, generic_name, path_kv.key });
......@@ -434,7 +434,7 @@ pub fn main() !void {
434434 }
435435 var hash_it = path_kv.value.iterator();
436436 while (hash_it.next()) |hash_kv| {
437 const contents = &hash_to_contents.get(hash_kv.value).?;
437 const contents = &hash_to_contents.getEntry(hash_kv.value).?.value;
438438 if (contents.is_generic) continue;
439439
440440 const dest_target = hash_kv.key;