go.net/publicsuffix: when generating table.go, track how much slack we
have in the bit-packing.
This was previously printed to stderr by gen.go, but is now written to
the generated table.go, so that we have better records of how it
changes over time.
LGTM=dr.volker.dobler
R=dr.volker.dobler
CC=golang-codereviews
https://golang.org/cl/89090043
diff --git a/publicsuffix/gen.go b/publicsuffix/gen.go
index c4263c6..61c1f40 100644
--- a/publicsuffix/gen.go
+++ b/publicsuffix/gen.go
@@ -234,14 +234,6 @@
return err
}
- if *v {
- fmt.Fprintf(os.Stderr, "max children %d (capacity %d)\n", maxChildren, 1<<nodesBitsChildren-1)
- fmt.Fprintf(os.Stderr, "max text offset %d (capacity %d)\n", maxTextOffset, 1<<nodesBitsTextOffset-1)
- fmt.Fprintf(os.Stderr, "max text length %d (capacity %d)\n", maxTextLength, 1<<nodesBitsTextLength-1)
- fmt.Fprintf(os.Stderr, "max hi %d (capacity %d)\n", maxHi, 1<<childrenBitsHi-1)
- fmt.Fprintf(os.Stderr, "max lo %d (capacity %d)\n", maxLo, 1<<childrenBitsLo-1)
- }
-
b, err := format.Source(buf.Bytes())
if err != nil {
return err
@@ -378,7 +370,12 @@
fmt.Fprintf(w, "0x%08x, // c0x%04x (%s)%s %s\n",
c, i, s, wildcardStr(wildcard), nodeTypeStr(nodeType))
}
- fmt.Fprintf(w, "}\n")
+ fmt.Fprintf(w, "}\n\n")
+ fmt.Fprintf(w, "// max children %d (capacity %d)\n", maxChildren, 1<<nodesBitsChildren-1)
+ fmt.Fprintf(w, "// max text offset %d (capacity %d)\n", maxTextOffset, 1<<nodesBitsTextOffset-1)
+ fmt.Fprintf(w, "// max text length %d (capacity %d)\n", maxTextLength, 1<<nodesBitsTextLength-1)
+ fmt.Fprintf(w, "// max hi %d (capacity %d)\n", maxHi, 1<<childrenBitsHi-1)
+ fmt.Fprintf(w, "// max lo %d (capacity %d)\n", maxLo, 1<<childrenBitsLo-1)
return nil
}
diff --git a/publicsuffix/table.go b/publicsuffix/table.go
index 3b62d1c..e08f235 100644
--- a/publicsuffix/table.go
+++ b/publicsuffix/table.go
@@ -7376,3 +7376,9 @@
0x066d19a8, // c0x016e (n0x19a8-n0x19b4) +
0x066ed9b4, // c0x016f (n0x19b4-n0x19bb) +
}
+
+// max children 367 (capacity 511)
+// max text offset 23226 (capacity 32767)
+// max text length 36 (capacity 63)
+// max hi 6587 (capacity 16383)
+// max lo 6580 (capacity 16383)