Fix UnmarshalJSON benchmark

Optimize MarshalJSON a little more
This commit is contained in:
zeroZshadow
2016-06-11 03:48:54 +02:00
parent c676f9e9ea
commit bb0fb2c0f5
2 changed files with 7 additions and 6 deletions

View File

@@ -127,7 +127,8 @@ func (f ID) Step() int64 {
// MarshalJSON returns a json byte array string of the snowflake ID.
func (f ID) MarshalJSON() ([]byte, error) {
buff := []byte("\"")
buff := make([]byte, 0, 2)
buff = append(buff, '"')
buff = strconv.AppendInt(buff, int64(f), 10)
buff = append(buff, '"')
return buff, nil