aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/type.go
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@golang.org>2016-06-24 15:28:58 -0400
committerDavid Crawshaw <crawshaw@golang.org>2016-06-24 20:05:34 +0000
commit797dc584577c66ee1e181a3f423133ee83647247 (patch)
tree52a21ef5b2605a37728bbe572a2cfa54eebe1b68 /src/runtime/type.go
parent2834526fd9de26079bebc726d3ce3ccaaf38a0aa (diff)
downloadgo-797dc584577c66ee1e181a3f423133ee83647247.tar.gz
go-797dc584577c66ee1e181a3f423133ee83647247.zip
cmd/compile, etc: use tflag to optimize Name()==""
Improves JSON decoding benchmark: name old time/op new time/op delta CodeDecoder-8 41.3ms ± 6% 39.8ms ± 1% -3.61% (p=0.000 n=10+10) name old speed new speed delta CodeDecoder-8 47.0MB/s ± 6% 48.7MB/s ± 1% +3.66% (p=0.000 n=10+10) Change-Id: I524ee05c432fad5252e79b29222ec635c1dee4b4 Reviewed-on: https://go-review.googlesource.com/24452 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/type.go')
-rw-r--r--src/runtime/type.go24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/runtime/type.go b/src/runtime/type.go
index 5ae5c73a22..49d3855e4d 100644
--- a/src/runtime/type.go
+++ b/src/runtime/type.go
@@ -19,6 +19,7 @@ type tflag uint8
const (
tflagUncommon tflag = 1 << 0
tflagExtraStar tflag = 1 << 1
+ tflagNamed tflag = 1 << 2
)
// Needs to be in sync with ../cmd/compile/internal/ld/decodesym.go:/^func.commonsize,
@@ -116,29 +117,10 @@ func hasPrefix(s, prefix string) bool {
}
func (t *_type) name() string {
- s := t.string()
- if hasPrefix(s, "map[") {
- return ""
- }
- if hasPrefix(s, "struct {") {
- return ""
- }
- if hasPrefix(s, "chan ") {
- return ""
- }
- if hasPrefix(s, "chan<-") {
- return ""
- }
- if hasPrefix(s, "func(") {
- return ""
- }
- if hasPrefix(s, "interface {") {
- return ""
- }
- switch s[0] {
- case '[', '*', '<':
+ if t.tflag&tflagNamed == 0 {
return ""
}
+ s := t.string()
i := len(s) - 1
for i >= 0 {
if s[i] == '.' {