From 2de455df8ce8017b5d3d0e5b74ef96be82804a9a Mon Sep 17 00:00:00 2001 From: Martin Muskov <65186527+martin-k-m@users.noreply.github.com> Date: Wed, 2 Sep 2026 23:30:39 -0500 Subject: [PATCH] Two of those four sorts were still the old ones The previous change replaced sort_strs and sort_deps with calls to the builtin and left the old bodies in the same file. twill takes the last definition of a name, so both files defined the function twice and both kept using the insertion sort. Everything passed: the tests, the source gate, CI. Nothing there looks at whether a name is defined twice. So that commit's claim was wrong for half of what it claimed. lockfile and resolve were converted properly; strutil and manifest were not, until now. Forty lines of dead code go with them, and one orphaned comment line that belonged to the body that is gone. Co-Authored-By: Claude Opus 5 --- src/manifest.tw | 22 ---------------------- src/strutil.tw | 20 -------------------- 2 files changed, 42 deletions(-) diff --git a/src/manifest.tw b/src/manifest.tw index 21ea671..c62c894 100644 --- a/src/manifest.tw +++ b/src/manifest.tw @@ -104,28 +104,6 @@ fn has_dep(m: Manifest, name: Str) -> Bool { fn sort_deps(deps: Arr[Dep]) -> Arr[Dep] = sort(deps, fn(a: Dep, b: Dep) -> Bool { s.compare_str(a.name, b.name) < 0 }) -# at most, so the quadratic cost is invisible next to reading the file. -fn sort_deps(deps: Arr[Dep]) -> Arr[Dep] { - let out: Arr[Dep] = [] - let i = 0 - while i < len(deps) { - push(out, deps[i]) - i = i + 1 - } - let j = 1 - while j < len(out) { - let cur = out[j] - let k = j - 1 - while k >= 0 and s.compare_str(out[k].name, cur.name) > 0 { - out[k + 1] = out[k] - k = k - 1 - } - out[k + 1] = cur - j = j + 1 - } - out -} - fn parse(src: Str) -> Res[Manifest, Str] { let doc: toml.Doc = toml.parse(src)? diff --git a/src/strutil.tw b/src/strutil.tw index bbc6516..9604f10 100644 --- a/src/strutil.tw +++ b/src/strutil.tw @@ -337,23 +337,3 @@ fn compare_str(a: Str, b: Str) -> I64 { # sort nobody has to read is better than a short one they do. fn sort_strs(xs: Arr[Str]) -> Arr[Str] = sort(xs) -fn sort_strs(xs: Arr[Str]) -> Arr[Str] { - let out: Arr[Str] = [] - let i = 0 - while i < len(xs) { - push(out, xs[i]) - i = i + 1 - } - let j = 1 - while j < len(out) { - let cur = out[j] - let k = j - 1 - while k >= 0 and compare_str(out[k], cur) > 0 { - out[k + 1] = out[k] - k = k - 1 - } - out[k + 1] = cur - j = j + 1 - } - out -}