diff options
| author | Josh Bleecher Snyder <josh@tailscale.com> | 2021-05-10 17:51:25 -0700 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2021-05-11 11:33:17 -0700 |
| commit | 8368bac847c4cdae9d2ecd652a28a19662bdd50a (patch) | |
| tree | 244d52eefc06218aceac24853965c0ae3cda060a | |
| parent | dfa0c9095505f447e04ddea32939ee8c5f876699 (diff) | |
| download | tailscale-8368bac847c4cdae9d2ecd652a28a19662bdd50a.tar.xz tailscale-8368bac847c4cdae9d2ecd652a28a19662bdd50a.zip | |
internal/deepprint: stop printing struct field names
The struct field names don't change within a single run,
so they are irrelevant. Use the field index instead.
name old time/op new time/op delta
Hash-8 6.52µs ± 0% 6.64µs ± 0% +1.91% (p=0.000 n=6+9)
name old alloc/op new alloc/op delta
Hash-8 1.67kB ± 0% 1.54kB ± 0% -7.66% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
Hash-8 53.0 ± 0% 37.0 ± 0% -30.19% (p=0.000 n=10+10)
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
| -rw-r--r-- | internal/deepprint/deepprint.go | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/internal/deepprint/deepprint.go b/internal/deepprint/deepprint.go index ddc48d2fc..ef846fce6 100644 --- a/internal/deepprint/deepprint.go +++ b/internal/deepprint/deepprint.go @@ -133,11 +133,8 @@ func print(w *bufio.Writer, v reflect.Value, visited map[uintptr]bool) { return case reflect.Struct: w.WriteString("struct{\n") - t := v.Type() for i, n := 0, v.NumField(); i < n; i++ { - sf := t.Field(i) - w.WriteString(sf.Name) - w.WriteString(": ") + fmt.Fprintf(w, " [%d]: ", i) print(w, v.Field(i), visited) w.WriteString("\n") } |
