Sync changes to internal version:
	        	- use append built-in
                        - remove NewT from commentary
	                - some idiom changes

R=r
CC=golang-dev
http://codereview.appspot.com/2926042
diff --git a/compiler/generator/generator.go b/compiler/generator/generator.go
index f64b5d4..2f9aebe 100644
--- a/compiler/generator/generator.go
+++ b/compiler/generator/generator.go
@@ -71,14 +71,7 @@
 // RegisterPlugin installs a (second-order) plugin to be run when the Go output is generated.
 // It is typically called during initialization.
 func RegisterPlugin(p Plugin) {
-	n := len(plugins)
-	if cap(plugins) == n {
-		nplugins := make([]Plugin, n, n+10) // very unlikely to need more than this
-		copy(nplugins, plugins)
-		plugins = nplugins
-	}
-	plugins = plugins[0 : n+1]
-	plugins[n] = p
+	plugins = append(plugins, p)
 }
 
 // Each type we import as a protocol buffer (other than FileDescriptorProto) needs
@@ -438,14 +431,7 @@
 		d.ext[i] = &ExtensionDescriptor{common{File: file}, field, d}
 	}
 
-	if len(sl) == cap(sl) {
-		nsl := make([]*Descriptor, len(sl), 2*len(sl))
-		copy(nsl, sl)
-		sl = nsl
-	}
-	sl = sl[0 : len(sl)+1]
-	sl[len(sl)-1] = d
-	return sl
+	return append(sl, d)
 }
 
 // Return a slice of all the Descriptors defined within this file
@@ -469,14 +455,7 @@
 
 // Construct the EnumDescriptor and add it to the slice
 func addEnumDescriptor(sl []*EnumDescriptor, desc *descriptor.EnumDescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto) []*EnumDescriptor {
-	if len(sl) == cap(sl) {
-		nsl := make([]*EnumDescriptor, len(sl), 2*len(sl))
-		copy(nsl, sl)
-		sl = nsl
-	}
-	sl = sl[0 : len(sl)+1]
-	sl[len(sl)-1] = &EnumDescriptor{common{File: file}, desc, parent, nil}
-	return sl
+	return append(sl, &EnumDescriptor{common{File: file}, desc, parent, nil})
 }
 
 // Return a slice of all the EnumDescriptors defined within this file
diff --git a/compiler/testdata/extension_test.go b/compiler/testdata/extension_test.go
index 85c7d56..8c805da 100644
--- a/compiler/testdata/extension_test.go
+++ b/compiler/testdata/extension_test.go
@@ -42,8 +42,9 @@
 )
 
 func TestSingleFieldExtension(t *testing.T) {
-	bm := &base.BaseMessage{}
-	bm.Height = proto.Int32(178)
+	bm := &base.BaseMessage{
+		Height: proto.Int32(178),
+	}
 
 	// Use extension within scope of another type.
 	vol := proto.Uint32(11)
@@ -55,7 +56,7 @@
 	if err != nil {
 		t.Fatal("Failed encoding message with extension:", err)
 	}
-	bm_new := &base.BaseMessage{}
+	bm_new := new(base.BaseMessage)
 	if err := proto.Unmarshal(buf, bm_new); err != nil {
 		t.Fatal("Failed decoding message with extension:", err)
 	}
@@ -76,8 +77,9 @@
 }
 
 func TestMessageExtension(t *testing.T) {
-	bm := &base.BaseMessage{}
-	bm.Height = proto.Int32(179)
+	bm := &base.BaseMessage{
+		Height: proto.Int32(179),
+	}
 
 	// Use extension that is itself a message.
 	um := &user.UserMessage{
@@ -92,7 +94,7 @@
 	if err != nil {
 		t.Fatal("Failed encoding message with extension:", err)
 	}
-	bm_new := &base.BaseMessage{}
+	bm_new := new(base.BaseMessage)
 	if err := proto.Unmarshal(buf, bm_new); err != nil {
 		t.Fatal("Failed decoding message with extension:", err)
 	}
@@ -116,8 +118,9 @@
 }
 
 func TestTopLevelExtension(t *testing.T) {
-	bm := &base.BaseMessage{}
-	bm.Height = proto.Int32(179)
+	bm := &base.BaseMessage{
+		Height: proto.Int32(179),
+	}
 
 	width := proto.Int32(17)
 	err := proto.SetExtension(bm, user.E_Width, width)
@@ -128,7 +131,7 @@
 	if err != nil {
 		t.Fatal("Failed encoding message with extension:", err)
 	}
-	bm_new := &base.BaseMessage{}
+	bm_new := new(base.BaseMessage)
 	if err := proto.Unmarshal(buf, bm_new); err != nil {
 		t.Fatal("Failed decoding message with extension:", err)
 	}