Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultDecoderBufferSize is the initial buffer size of StreamDecoder DefaultDecoderBufferSize uint = 4 * 1024 // DefaultEncoderBufferSize is the initial buffer size of Encoder DefaultEncoderBufferSize uint = 4 * 1024 // DefaultAstBufferSize is the initial buffer size of ast.Node.MarshalJSON() DefaultAstBufferSize uint = 4 * 1024 // LimitBufferSize indicates the max pool buffer size, in case of OOM. // See issue https://github.com/bytedance/sonic/issues/614 LimitBufferSize uint = 1024 * 1024 )
var ( // Default value(3) means the compiler only inline 3 layers of nested struct. // when the depth exceeds, the compiler will recurse // and compile subsequent structs when they are decoded DefaultMaxInlineDepth = 3 // Default value(1) means `Pretouch()` will be recursively executed once, // if any nested struct is left (depth exceeds MaxInlineDepth) DefaultRecursiveDepth = 1 )
Functions ¶
This section is empty.
Types ¶
type CompileOption ¶
type CompileOption func(o *CompileOptions)
CompileOption is a function used to change DefaultCompileOptions.
func WithCompileEncOnlyOmitNull ¶ added in v1.15.1
func WithCompileEncOnlyOmitNull(omit bool) CompileOption
WithCompileEncOnlyOmitNull sets the encoder to only omit nil value instead of zero value with `omitempty` tag.
func WithCompileMaxInlineDepth ¶ added in v1.4.0
func WithCompileMaxInlineDepth(depth int) CompileOption
WithCompileMaxInlineDepth sets the max depth of inline compile in decoder and encoder.
For large nested struct, try to set smaller depth to reduce compiling time.
func WithCompileRecursiveDepth ¶
func WithCompileRecursiveDepth(loop int) CompileOption
WithCompileRecursiveDepth sets the loop times of recursive pretouch in both decoder and encoder, for both concrete type and its pointer type.
For deep nested struct (depth exceeds MaxInlineDepth), try to set more loops to completely compile, thus reduce JIT instability in the first hit.
type CompileOptions ¶
type CompileOptions struct {
// the maximum depth for compilation inline
MaxInlineDepth int
// the loop times for recursively pretouch
RecursiveDepth int
// EncOnlyOmitNull sets the encoder to only omit nil value (ex: nil pointer, nil container) instead of zero value,
// with `omitempty` tag.
EncOnlyOmitNull bool
}
CompileOptions includes all options for encoder or decoder compiler.
func DefaultCompileOptions ¶
func DefaultCompileOptions() CompileOptions
DefaultCompileOptions set default compile options.