summaryrefslogtreecommitdiff
path: root/src/pkg/go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-03-23 16:56:48 -0700
committerRuss Cox <rsc@golang.org>2010-03-23 16:56:48 -0700
commit2c3c610c481dda8f412f4d0657fa3ef34f70057d (patch)
tree762a8a99ba4cfa9fb43f74803ef45fac3c358eaf /src/pkg/go
parent3214a9355ae4f328c1d8550e659d18dc823e2e9a (diff)
downloadgolang-2c3c610c481dda8f412f4d0657fa3ef34f70057d.tar.gz
go/printer: avoid reflect in print
R=gri CC=golang-dev http://codereview.appspot.com/704041
Diffstat (limited to 'src/pkg/go')
-rw-r--r--src/pkg/go/printer/printer.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/pkg/go/printer/printer.go b/src/pkg/go/printer/printer.go
index 4c530d249..17d9100f4 100644
--- a/src/pkg/go/printer/printer.go
+++ b/src/pkg/go/printer/printer.go
@@ -739,16 +739,13 @@ func (p *printer) writeWhitespace(n int) {
// space for best comment placement. Then, any leftover whitespace is
// printed, followed by the actual token.
//
-func (p *printer) print(args ...) {
- v := reflect.NewValue(args).(*reflect.StructValue)
- for i := 0; i < v.NumField(); i++ {
- f := v.Field(i)
-
+func (p *printer) print(args ...interface{}) {
+ for _, f := range args {
next := p.pos // estimated position of next item
var data []byte
var tag HTMLTag
isKeyword := false
- switch x := f.Interface().(type) {
+ switch x := f.(type) {
case whiteSpace:
if x == ignore {
// don't add ignore's to the buffer; they
@@ -795,7 +792,8 @@ func (p *printer) print(args ...) {
next = x // accurate position of next item
}
default:
- panicln("print: unsupported argument type", f.Type().String())
+ fmt.Fprintf(os.Stderr, "print: unsupported argument type %T\n", f)
+ panic()
}
p.pos = next