From 9cbe1bc91fa3c3dca182b31e7544dbdddbb63f9e Mon Sep 17 00:00:00 2001 From: Yorhel Date: Thu, 18 Jul 2024 21:43:18 +0200 Subject: [PATCH] Use slower and smaller heap sort for hardlink list Saves 20 KiB off of the ReleaseSafe + stripped binary. That feature is (1) rarely used and (2) rarely deals with large lists, so no point spending that much space on an efficient sort implementation. --- src/browser.zig | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/browser.zig b/src/browser.zig index a073138..81ff1c1 100644 --- a/src/browser.zig +++ b/src/browser.zig @@ -380,10 +380,7 @@ const info = struct { if (&l.entry == e) break; } - // TODO: Zig's sort() implementation is type-generic and not very - // small. I suspect we can get a good save on our binary size by using - // a smaller or non-generic sort. This doesn't have to be very fast. - std.mem.sort(*model.Link, list.items, {}, lt); + std.sort.heap(*model.Link, list.items, {}, lt); for (list.items, 0..) |n,i| if (&n.entry == e) { links_idx = i; }; links = list; }