Skip to content

Commit

Permalink
refactor option
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Jun 26, 2024
1 parent 6766f03 commit 2734012
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ast/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

`github.com/bytedance/sonic/internal/native/types`
`github.com/bytedance/sonic/internal/rt`
`github.com/bytedance/sonic/option`
)

const (
Expand Down Expand Up @@ -49,7 +50,7 @@ type Parser struct {
dbuf *byte
}

var noLazy bool = false
var noLazy = option.AstSafeConcurrentRead

/** Parser Private Methods **/

Expand Down
10 changes: 9 additions & 1 deletion option/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package option

import `os`

var (
// DefaultDecoderBufferSize is the initial buffer size of StreamDecoder
DefaultDecoderBufferSize uint = 128 * 1024
Expand Down Expand Up @@ -83,4 +85,10 @@ func WithCompileMaxInlineDepth(depth int) CompileOption {
o.MaxInlineDepth = depth
}
}


var (
// AstSafeConcurrentRead indicate that `sonic/ast.Node`` can be concurrently 'Read'
// (for `GetByPath/Get/Index/Int64/String/Bool/Float64/Number/Interface/Map/Array/ForEach/Values/Properties`)
// NOTICE: Use it may cause `ast.Node`` performace decline
AstSafeConcurrentRead = os.Getenv("SONIC_AST_SAFE_CONCURRENT_READ") != ""
)

0 comments on commit 2734012

Please sign in to comment.