Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(705)

Issue 9365044: code review 9365044: encoding/json: allocate less in NewEncoder (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 7 months ago by bradfitz
Modified:
12 years, 7 months ago
Reviewers:
CC:
r, gobot, golang-dev
Visibility:
Public.

Description

encoding/json: allocate less in NewEncoder The *Encoder is almost always garbage. It doesn't need an encodeState inside of it (and its bytes.Buffer), since it's only needed locally inside of Encode. benchmark old ns/op new ns/op delta BenchmarkEncoderEncode 2562 2553 -0.35% benchmark old bytes new bytes delta BenchmarkEncoderEncode 283 102 -63.96%

Patch Set 1 #

Patch Set 2 : diff -r 30c566874b83 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 30c566874b83 https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r 8e5aba451c65 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+38 lines, -4 lines) Patch
M src/pkg/encoding/json/encode.go View 1 1 chunk +20 lines, -0 lines 0 comments Download
M src/pkg/encoding/json/stream.go View 1 2 chunks +5 lines, -4 lines 0 comments Download
M src/pkg/encoding/json/stream_test.go View 1 1 chunk +13 lines, -0 lines 0 comments Download

Messages

Total messages: 4
bradfitz
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
12 years, 7 months ago (2013-05-12 23:53:42 UTC) #1
gobot
R=r (assigned by bradfitz)
12 years, 7 months ago (2013-05-14 22:15:05 UTC) #2
r
LGTM nice
12 years, 7 months ago (2013-05-14 22:46:22 UTC) #3
bradfitz
12 years, 7 months ago (2013-05-14 22:50:50 UTC) #4
*** Submitted as https://code.google.com/p/go/source/detail?r=00d69aa6619e ***

encoding/json: allocate less in NewEncoder

The *Encoder is almost always garbage. It doesn't need an
encodeState inside of it (and its bytes.Buffer), since it's
only needed locally inside of Encode.

benchmark                 old ns/op    new ns/op    delta
BenchmarkEncoderEncode         2562         2553   -0.35%

benchmark                 old bytes    new bytes    delta
BenchmarkEncoderEncode          283          102  -63.96%

R=r
CC=gobot, golang-dev
https://codereview.appspot.com/9365044
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b