authorgravatar for admin@15318.deCassidy Dingenskirchen <admin@15318.de> 2020-06-12 16:32:02+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-06-12 13:33:31-04:00
log57f1ed5325eeb3c3ca62af62a104f840881248f0
treee4d51ad2253abd16d569f0abc160d883512c43e5
parent7d8fd452672e1fcf3692da0f52d480415b67e1ea

Fix a few std.sort.sort invocations


5 files changed, 16 insertions(+), 16 deletions(-)

lib/std/build/emit_raw.zig+4-4
...@@ -92,7 +92,7 @@ const BinaryElfOutput = struct {...@@ -92,7 +92,7 @@ const BinaryElfOutput = struct {
92 }92 }
93 }93 }
9494
95 sort.sort(*BinaryElfSegment, self.segments.span(), segmentSortCompare);95 sort.sort(*BinaryElfSegment, self.segments.span(), {}, segmentSortCompare);
9696
97 if (self.segments.items.len > 0) {97 if (self.segments.items.len > 0) {
98 const firstSegment = self.segments.items[0];98 const firstSegment = self.segments.items[0];
...@@ -117,7 +117,7 @@ const BinaryElfOutput = struct {...@@ -117,7 +117,7 @@ const BinaryElfOutput = struct {
117 }117 }
118 }118 }
119119
120 sort.sort(*BinaryElfSection, self.sections.span(), sectionSortCompare);120 sort.sort(*BinaryElfSection, self.sections.span(), {}, sectionSortCompare);
121121
122 return self;122 return self;
123 }123 }
...@@ -131,7 +131,7 @@ const BinaryElfOutput = struct {...@@ -131,7 +131,7 @@ const BinaryElfOutput = struct {
131 ((shdr.sh_flags & elf.SHF_ALLOC) == elf.SHF_ALLOC);131 ((shdr.sh_flags & elf.SHF_ALLOC) == elf.SHF_ALLOC);
132 }132 }
133133
134 fn segmentSortCompare(left: *BinaryElfSegment, right: *BinaryElfSegment) bool {134 fn segmentSortCompare(context: void, left: *BinaryElfSegment, right: *BinaryElfSegment) bool {
135 if (left.physicalAddress < right.physicalAddress) {135 if (left.physicalAddress < right.physicalAddress) {
136 return true;136 return true;
137 }137 }
...@@ -141,7 +141,7 @@ const BinaryElfOutput = struct {...@@ -141,7 +141,7 @@ const BinaryElfOutput = struct {
141 return false;141 return false;
142 }142 }
143143
144 fn sectionSortCompare(left: *BinaryElfSection, right: *BinaryElfSection) bool {144 fn sectionSortCompare(context: void, left: *BinaryElfSection, right: *BinaryElfSection) bool {
145 return left.binaryOffset < right.binaryOffset;145 return left.binaryOffset < right.binaryOffset;
146 }146 }
147};147};
lib/std/meta.zig+4-4
...@@ -145,8 +145,8 @@ test "std.meta.Child" {...@@ -145,8 +145,8 @@ test "std.meta.Child" {
145/// Given a "memory span" type, returns the "element type".145/// Given a "memory span" type, returns the "element type".
146pub fn Elem(comptime T: type) type {146pub fn Elem(comptime T: type) type {
147 switch (@typeInfo(T)) {147 switch (@typeInfo(T)) {
148 .Array, => |info| return info.child,148 .Array => |info| return info.child,
149 .Vector, => |info| return info.child,149 .Vector => |info| return info.child,
150 .Pointer => |info| switch (info.size) {150 .Pointer => |info| switch (info.size) {
151 .One => switch (@typeInfo(info.child)) {151 .One => switch (@typeInfo(info.child)) {
152 .Array => |array_info| return array_info.child,152 .Array => |array_info| return array_info.child,
...@@ -658,7 +658,7 @@ pub fn refAllDecls(comptime T: type) void {...@@ -658,7 +658,7 @@ pub fn refAllDecls(comptime T: type) void {
658/// Returns a slice of pointers to public declarations of a namespace.658/// Returns a slice of pointers to public declarations of a namespace.
659pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl {659pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl {
660 const S = struct {660 const S = struct {
661 fn declNameLessThan(lhs: *const Decl, rhs: *const Decl) bool {661 fn declNameLessThan(context: void, lhs: *const Decl, rhs: *const Decl) bool {
662 return mem.lessThan(u8, lhs.name, rhs.name);662 return mem.lessThan(u8, lhs.name, rhs.name);
663 }663 }
664 };664 };
...@@ -668,7 +668,7 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De...@@ -668,7 +668,7 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De
668 for (decls) |decl, i| {668 for (decls) |decl, i| {
669 array[i] = &@field(Namespace, decl.name);669 array[i] = &@field(Namespace, decl.name);
670 }670 }
671 std.sort.sort(*const Decl, &array, S.declNameLessThan);671 std.sort.sort(*const Decl, &array, {}, S.declNameLessThan);
672 return &array;672 return &array;
673 }673 }
674}674}
tools/process_headers.zig+2-2
...@@ -242,7 +242,7 @@ const Contents = struct {...@@ -242,7 +242,7 @@ const Contents = struct {
242 hash: []const u8,242 hash: []const u8,
243 is_generic: bool,243 is_generic: bool,
244244
245 fn hitCountLessThan(lhs: *const Contents, rhs: *const Contents) bool {245 fn hitCountLessThan(context: void, lhs: *const Contents, rhs: *const Contents) bool {
246 return lhs.hit_count < rhs.hit_count;246 return lhs.hit_count < rhs.hit_count;
247 }247 }
248};248};
...@@ -414,7 +414,7 @@ pub fn main() !void {...@@ -414,7 +414,7 @@ pub fn main() !void {
414 try contents_list.append(contents);414 try contents_list.append(contents);
415 }415 }
416 }416 }
417 std.sort.sort(*Contents, contents_list.span(), Contents.hitCountLessThan);417 std.sort.sort(*Contents, contents_list.span(), {}, Contents.hitCountLessThan);
418 var best_contents = contents_list.popOrNull().?;418 var best_contents = contents_list.popOrNull().?;
419 if (best_contents.hit_count > 1) {419 if (best_contents.hit_count > 1) {
420 // worth it to make it generic420 // worth it to make it generic
tools/update_clang_options.zig+2-2
...@@ -352,7 +352,7 @@ pub fn main() anyerror!void {...@@ -352,7 +352,7 @@ pub fn main() anyerror!void {
352 }352 }
353 // Some options have multiple matches. As an example, "-Wl,foo" matches both353 // Some options have multiple matches. As an example, "-Wl,foo" matches both
354 // "W" and "Wl,". So we sort this list in order of descending priority.354 // "W" and "Wl,". So we sort this list in order of descending priority.
355 std.sort.sort(*json.ObjectMap, all_objects.span(), objectLessThan);355 std.sort.sort(*json.ObjectMap, all_objects.span(), {}, objectLessThan);
356356
357 var stdout_bos = std.io.bufferedOutStream(std.io.getStdOut().outStream());357 var stdout_bos = std.io.bufferedOutStream(std.io.getStdOut().outStream());
358 const stdout = stdout_bos.outStream();358 const stdout = stdout_bos.outStream();
...@@ -544,7 +544,7 @@ fn syntaxMatchesWithEql(syntax: Syntax) bool {...@@ -544,7 +544,7 @@ fn syntaxMatchesWithEql(syntax: Syntax) bool {
544 };544 };
545}545}
546546
547fn objectLessThan(a: *json.ObjectMap, b: *json.ObjectMap) bool {547fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool {
548 // Priority is determined by exact matches first, followed by prefix matches in descending548 // Priority is determined by exact matches first, followed by prefix matches in descending
549 // length, with key as a final tiebreaker.549 // length, with key as a final tiebreaker.
550 const a_syntax = objSyntax(a);550 const a_syntax = objSyntax(a);
tools/update_glibc.zig+4-4
...@@ -225,14 +225,14 @@ pub fn main() !void {...@@ -225,14 +225,14 @@ pub fn main() !void {
225 var list = std.ArrayList([]const u8).init(allocator);225 var list = std.ArrayList([]const u8).init(allocator);
226 var it = global_fn_set.iterator();226 var it = global_fn_set.iterator();
227 while (it.next()) |kv| try list.append(kv.key);227 while (it.next()) |kv| try list.append(kv.key);
228 std.sort.sort([]const u8, list.span(), strCmpLessThan);228 std.sort.sort([]const u8, list.span(), {}, strCmpLessThan);
229 break :blk list.span();229 break :blk list.span();
230 };230 };
231 const global_ver_list = blk: {231 const global_ver_list = blk: {
232 var list = std.ArrayList([]const u8).init(allocator);232 var list = std.ArrayList([]const u8).init(allocator);
233 var it = global_ver_set.iterator();233 var it = global_ver_set.iterator();
234 while (it.next()) |kv| try list.append(kv.key);234 while (it.next()) |kv| try list.append(kv.key);
235 std.sort.sort([]const u8, list.span(), versionLessThan);235 std.sort.sort([]const u8, list.span(), {}, versionLessThan);
236 break :blk list.span();236 break :blk list.span();
237 };237 };
238 {238 {
...@@ -311,11 +311,11 @@ pub fn main() !void {...@@ -311,11 +311,11 @@ pub fn main() !void {
311 }311 }
312}312}
313313
314pub fn strCmpLessThan(a: []const u8, b: []const u8) bool {314pub fn strCmpLessThan(context: void, a: []const u8, b: []const u8) bool {
315 return std.mem.order(u8, a, b) == .lt;315 return std.mem.order(u8, a, b) == .lt;
316}316}
317317
318pub fn versionLessThan(a: []const u8, b: []const u8) bool {318pub fn versionLessThan(context: void, a: []const u8, b: []const u8) bool {
319 const sep_chars = "GLIBC_.";319 const sep_chars = "GLIBC_.";
320 var a_tokens = std.mem.tokenize(a, sep_chars);320 var a_tokens = std.mem.tokenize(a, sep_chars);
321 var b_tokens = std.mem.tokenize(b, sep_chars);321 var b_tokens = std.mem.tokenize(b, sep_chars);