Skip to content

Commit

Permalink
idx2rwmap: do not sort by serving path
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stapelberg committed Aug 5, 2023
1 parent c35ad7d commit adb0794
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions cmd/debiman-idx2rwmap/rwmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"os"
"path/filepath"
"runtime"
"sort"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -71,20 +70,6 @@ func (op oncePrinter) mustPrint(key string, template redirect.IndexEntry) {
op.printed[key] = true
}

type byServingPath []redirect.IndexEntry

func (p byServingPath) Len() int {
return len(p)
}

func (p byServingPath) Swap(i, j int) {
p[i], p[j] = p[j], p[i]
}

func (p byServingPath) Less(i, j int) bool {
return p[i].ServingPath(".html") < p[j].ServingPath(".html")
}

func printAll(bufw *bufio.Writer, idx redirect.Index, name string) {
variants := idx.Entries[name]

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

// sort to make the output deterministic
sort.Stable(byServingPath(variants))

for _, v := range variants {
suites := []string{v.Suite}
for name, rewrite := range idx.Suites {
Expand Down

0 comments on commit adb0794

Please sign in to comment.