forked from mirror/go-json
Merge pull request #27 from goccy/feature/improve-performance
Improve encoder performance ( remove unnecessary reference )
This commit is contained in:
commit
12c1c98305
|
@ -14,7 +14,6 @@ import (
|
||||||
type Encoder struct {
|
type Encoder struct {
|
||||||
w io.Writer
|
w io.Writer
|
||||||
buf []byte
|
buf []byte
|
||||||
pool sync.Pool
|
|
||||||
enabledIndent bool
|
enabledIndent bool
|
||||||
enabledHTMLEscape bool
|
enabledHTMLEscape bool
|
||||||
prefix []byte
|
prefix []byte
|
||||||
|
@ -65,7 +64,6 @@ func init() {
|
||||||
New: func() interface{} {
|
New: func() interface{} {
|
||||||
return &Encoder{
|
return &Encoder{
|
||||||
buf: make([]byte, 0, bufSize),
|
buf: make([]byte, 0, bufSize),
|
||||||
pool: encPool,
|
|
||||||
structTypeToCompiledCode: map[uintptr]*compiledCode{},
|
structTypeToCompiledCode: map[uintptr]*compiledCode{},
|
||||||
structTypeToCompiledIndentCode: map[uintptr]*compiledCode{},
|
structTypeToCompiledIndentCode: map[uintptr]*compiledCode{},
|
||||||
}
|
}
|
||||||
|
@ -119,7 +117,7 @@ func (e *Encoder) SetIndent(prefix, indent string) {
|
||||||
|
|
||||||
func (e *Encoder) release() {
|
func (e *Encoder) release() {
|
||||||
e.w = nil
|
e.w = nil
|
||||||
e.pool.Put(e)
|
encPool.Put(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Encoder) reset() {
|
func (e *Encoder) reset() {
|
||||||
|
|
Loading…
Reference in New Issue