Skip to content

Commit adb0794

Browse files
committed
idx2rwmap: do not sort by serving path
this is a revert of commit 4c40626 I’m not sure what was non-deterministic about the output back then, but redirect.IndexFromProto() returns entries in the order in which they were loaded from the index. Maybe non-determinism was addressed at a different stage in the meantime. An unintended side-effect of the sorting was a preference for uppercase paths, as they come first in ASCII. Removing the sorting removes a behavioral difference between serving the redirect index via auxserver and using idx2rwmap. related to #161
1 parent c35ad7d commit adb0794

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

cmd/debiman-idx2rwmap/rwmap.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"os"
2323
"path/filepath"
2424
"runtime"
25-
"sort"
2625
"strconv"
2726
"strings"
2827
"sync"
@@ -71,20 +70,6 @@ func (op oncePrinter) mustPrint(key string, template redirect.IndexEntry) {
7170
op.printed[key] = true
7271
}
7372

74-
type byServingPath []redirect.IndexEntry
75-
76-
func (p byServingPath) Len() int {
77-
return len(p)
78-
}
79-
80-
func (p byServingPath) Swap(i, j int) {
81-
p[i], p[j] = p[j], p[i]
82-
}
83-
84-
func (p byServingPath) Less(i, j int) bool {
85-
return p[i].ServingPath(".html") < p[j].ServingPath(".html")
86-
}
87-
8873
func printAll(bufw *bufio.Writer, idx redirect.Index, name string) {
8974
variants := idx.Entries[name]
9075

@@ -95,9 +80,6 @@ func printAll(bufw *bufio.Writer, idx redirect.Index, name string) {
9580
variants: variants,
9681
}
9782

98-
// sort to make the output deterministic
99-
sort.Stable(byServingPath(variants))
100-
10183
for _, v := range variants {
10284
suites := []string{v.Suite}
10385
for name, rewrite := range idx.Suites {

0 commit comments

Comments
 (0)