goprotobuf: Simplify helper functions (Int32, etc.).
R=r
CC=golang-dev
https://codereview.appspot.com/12644043
diff --git a/proto/lib.go b/proto/lib.go
index dfb4206..fa6fe22 100644
--- a/proto/lib.go
+++ b/proto/lib.go
@@ -332,17 +332,13 @@
// Bool is a helper routine that allocates a new bool value
// to store v and returns a pointer to it.
func Bool(v bool) *bool {
- p := new(bool)
- *p = v
- return p
+ return &v
}
// Int32 is a helper routine that allocates a new int32 value
// to store v and returns a pointer to it.
func Int32(v int32) *int32 {
- p := new(int32)
- *p = v
- return p
+ return &v
}
// Int is a helper routine that allocates a new int32 value
@@ -357,25 +353,19 @@
// Int64 is a helper routine that allocates a new int64 value
// to store v and returns a pointer to it.
func Int64(v int64) *int64 {
- p := new(int64)
- *p = v
- return p
+ return &v
}
// Float32 is a helper routine that allocates a new float32 value
// to store v and returns a pointer to it.
func Float32(v float32) *float32 {
- p := new(float32)
- *p = v
- return p
+ return &v
}
// Float64 is a helper routine that allocates a new float64 value
// to store v and returns a pointer to it.
func Float64(v float64) *float64 {
- p := new(float64)
- *p = v
- return p
+ return &v
}
// Uint32 is a helper routine that allocates a new uint32 value
@@ -389,17 +379,13 @@
// Uint64 is a helper routine that allocates a new uint64 value
// to store v and returns a pointer to it.
func Uint64(v uint64) *uint64 {
- p := new(uint64)
- *p = v
- return p
+ return &v
}
// String is a helper routine that allocates a new string value
// to store v and returns a pointer to it.
func String(v string) *string {
- p := new(string)
- *p = v
- return p
+ return &v
}
// EnumName is a helper function to simplify printing protocol buffer enums