diff options
author | David Crawshaw <crawshaw@golang.org> | 2016-02-17 13:03:21 -0500 |
---|---|---|
committer | David Crawshaw <crawshaw@golang.org> | 2016-02-26 12:02:39 +0000 |
commit | 0231f5420f22c40ce9c15ef4d3f51ce0bafa7fef (patch) | |
tree | 340d2eb40a47c3e7a1831fc117a8afc67c6f5a09 /src/runtime/type.go | |
parent | c8ae2e82c7262df1fa902b847e09f0aa776e7ccd (diff) | |
download | go-0231f5420f22c40ce9c15ef4d3f51ce0bafa7fef.tar.gz go-0231f5420f22c40ce9c15ef4d3f51ce0bafa7fef.zip |
cmd/compile: remove uncommonType.name
Reduces binary size of cmd/go by 0.5%.
For #6853.
Change-Id: I5a4b814049580ab5098ad252d979f80b70d8a5f9
Reviewed-on: https://go-review.googlesource.com/19694
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/type.go')
-rw-r--r-- | src/runtime/type.go | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/runtime/type.go b/src/runtime/type.go index 8304ad7b77..18c6a32ecb 100644 --- a/src/runtime/type.go +++ b/src/runtime/type.go @@ -28,6 +28,36 @@ type _type struct { x *uncommontype } +func hasPrefix(s, prefix string) bool { + return len(s) >= len(prefix) && s[:len(prefix)] == prefix +} + +func (t *_type) name() string { + if hasPrefix(t._string, "map[") { + return "" + } + if hasPrefix(t._string, "struct {") { + return "" + } + if hasPrefix(t._string, "chan ") { + return "" + } + if hasPrefix(t._string, "func(") { + return "" + } + if t._string[0] == '[' || t._string[0] == '*' { + return "" + } + i := len(t._string) - 1 + for i >= 0 { + if t._string[i] == '.' { + break + } + i-- + } + return t._string[i+1:] +} + type method struct { name *string pkgpath *string @@ -38,7 +68,6 @@ type method struct { } type uncommontype struct { - name *string pkgpath *string mhdr []method } |