diff --git a/internal/decoder/api/decoder.go b/internal/decoder/api/decoder.go index 5e31198e1..d591edb50 100644 --- a/internal/decoder/api/decoder.go +++ b/internal/decoder/api/decoder.go @@ -17,16 +17,23 @@ package api import ( - `reflect` - - `github.com/bytedance/sonic/internal/native` - `github.com/bytedance/sonic/internal/native/types` - `github.com/bytedance/sonic/internal/decoder/consts` - `github.com/bytedance/sonic/internal/decoder/errors` - `github.com/bytedance/sonic/internal/rt` - `github.com/bytedance/sonic/option` + "reflect" + + "github.com/bytedance/sonic/internal/decoder/consts" + "github.com/bytedance/sonic/internal/decoder/errors" + "github.com/bytedance/sonic/internal/decoder/optdec" + "github.com/bytedance/sonic/internal/native" + "github.com/bytedance/sonic/internal/native/types" + "github.com/bytedance/sonic/internal/rt" + "github.com/bytedance/sonic/option" ) +func ForceAllOpt() { + decodeImpl = optdec.Decode + pretouchImpl = optdec.Pretouch + rt.EnbaleFastMap = true +} + const ( _F_allow_control = consts.F_allow_control _F_copy_string = consts.F_copy_string diff --git a/sonic.go b/sonic.go index a92981c41..7a88cc0a5 100644 --- a/sonic.go +++ b/sonic.go @@ -26,10 +26,19 @@ import ( `github.com/bytedance/sonic/decoder` `github.com/bytedance/sonic/encoder` + enc `github.com/bytedance/sonic/internal/encoder` + dec `github.com/bytedance/sonic/internal/decoder/api` + `github.com/bytedance/sonic/option` `github.com/bytedance/sonic/internal/rt` ) +func init() { + dec.ForceAllOpt() + enc.ForceUseVM() + println("Warning: enable all optimize here, only used in test now") +} + type frozenConfig struct { Config encoderOpts encoder.Options