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>
This commit is contained in:
David Crawshaw 2016-02-17 13:03:21 -05:00
parent c8ae2e82c7
commit 0231f5420f
6 changed files with 84 additions and 21 deletions

View file

@ -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
}