]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.2] cmd/gc: shorten name used for map bucket type
authorAndrew Gerrand <adg@golang.org>
Fri, 1 Nov 2013 00:00:12 +0000 (11:00 +1100)
committerAndrew Gerrand <adg@golang.org>
Fri, 1 Nov 2013 00:00:12 +0000 (11:00 +1100)
««« CL 15110044 / 95336afd420c
cmd/gc: shorten name used for map bucket type

Before:
type.struct { buckets *struct { overflow *struct { overflow *struct { overflow *struct { overflow *struct { overflow *<...>; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; oldbuckets *struct { overflow *struct { overflow *struct { overflow *struct { overflow *struct { overflow *<...>; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable } }

After:
type.map.bucket[string]*"".RangeTable

This makes debugging maps a little nicer, and it takes up less space in the binary.

R=golang-dev, r
CC=golang-dev, khr
https://golang.org/cl/15110044
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/20050044

src/cmd/gc/fmt.c
src/cmd/gc/reflect.c

index c525a56cbe7e8693ef8a00bff8fddf4cf54b90c2..9cd3448701463f9afbb521087a9d01004404ec90 100644 (file)
@@ -700,6 +700,13 @@ typefmt(Fmt *fp, Type *t)
                return 0;
 
        case TSTRUCT:
+               // Format the bucket struct for map[x]y as map.bucket[x]y.
+               // This avoids a recursive print that generates very long names.
+               if(t->hmap != T) {
+                       t = t->hmap;
+                       return fmtprint(fp, "map.bucket[%T]%T", t->down, t->type);
+               }
+
                if(t->funarg) {
                        fmtstrcpy(fp, "(");
                        if(fmtmode == FTypeId || fmtmode == FErr) {     // no argument names on function signature, and no "noescape" tags
index ea66eb94b202cc234869bc3a62698177dfd46ffa..0a8aa8d7a63a54ea84649d58aa7c299e806f340e 100644 (file)
@@ -229,6 +229,7 @@ hmap(Type *t)
        h->width = offset;
        h->local = t->local;
        t->hmap = h;
+       h->hmap = t;
        return h;
 }