add closest encloser stuff

This commit is contained in:
Miek Gieben
2016-03-30 16:45:02 +00:00
parent 3838eabda4
commit bf6d90600b
6 changed files with 62 additions and 18 deletions

View File

@@ -17,8 +17,11 @@ func Less(a, b string) int {
aj := len(a)
bj := len(b)
for {
ai, _ := dns.PrevLabel(a, i)
bi, _ := dns.PrevLabel(b, i)
ai, oka := dns.PrevLabel(a, i)
bi, okb := dns.PrevLabel(b, i)
if oka && okb {
return 0
}
// sadly this []byte will allocate...
ab := []byte(a[ai:aj])
toLowerAndDDD(ab)