aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-04-07 22:33:33 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-04-07 22:33:33 -0700
commitc764543af54352b7d09352f47f9edafe71fbb1b3 (patch)
treeb904ae40697f10f7d0cf96d204c88b9c6609f63d
parent60fc80d4c4602b11398f0332490136e8d216dab3 (diff)
downloadbun-c764543af54352b7d09352f47f9edafe71fbb1b3.tar.gz
bun-c764543af54352b7d09352f47f9edafe71fbb1b3.tar.zst
bun-c764543af54352b7d09352f47f9edafe71fbb1b3.zip
Fix sort
-rw-r--r--src/bundler/bundle_v2.zig9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig
index 4650f9e75..282d95b2f 100644
--- a/src/bundler/bundle_v2.zig
+++ b/src/bundler/bundle_v2.zig
@@ -7513,18 +7513,15 @@ pub const Chunk = struct {
tie_breaker: u32 = 0,
pub fn lessThan(_: @This(), a: Order, b: Order) bool {
- if (a.distance < b.distance) return true;
-
- return a.tie_breaker < b.tie_breaker;
+ return (a.distance < b.distance) or
+ (a.distance == b.distance and a.tie_breaker < b.tie_breaker);
}
/// Sort so files closest to an entry point come first. If two files are
/// equidistant to an entry point, then break the tie by sorting on the
/// stable source index derived from the DFS over all entry points.
pub fn sort(a: []Order) void {
- // https://github.com/ziglang/zig/issues/15204
- // Possibly switch to std.sort.sort when this is fixed
- std.sort.insertionSort(Order, a, Order{}, lessThan);
+ std.sort.sort(Order, a, Order{}, lessThan);
}
};