Skip to content

Commit e5ee6c2

Browse files
committed
Rename DisableSC to ShortCircuit for better clarity and consistency
1 parent 1973835 commit e5ee6c2

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

compiler/compiler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ func (c *compiler) BinaryNode(node *ast.BinaryNode) {
448448
c.emit(OpNot)
449449

450450
case "or", "||":
451-
if c.config != nil && c.config.DisableSC {
451+
if c.config != nil && !c.config.ShortCircuit {
452452
c.compile(node.Left)
453453
c.derefInNeeded(node.Left)
454454
c.compile(node.Right)
@@ -465,7 +465,7 @@ func (c *compiler) BinaryNode(node *ast.BinaryNode) {
465465
c.patchJump(end)
466466

467467
case "and", "&&":
468-
if c.config != nil && c.config.DisableSC {
468+
if c.config != nil && !c.config.ShortCircuit {
469469
c.compile(node.Left)
470470
c.derefInNeeded(node.Left)
471471
c.compile(node.Right)

conf/config.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,33 @@ var (
2121
type FunctionsTable map[string]*builtin.Function
2222

2323
type Config struct {
24-
EnvObject any
25-
Env nature.Nature
26-
Expect reflect.Kind
27-
ExpectAny bool
28-
Optimize bool
29-
Strict bool
30-
Profile bool
31-
MaxNodes uint
32-
ConstFns map[string]reflect.Value
33-
Visitors []ast.Visitor
34-
Functions FunctionsTable
35-
Builtins FunctionsTable
36-
Disabled map[string]bool // disabled builtins
37-
NtCache nature.Cache
38-
DisableSC bool
24+
EnvObject any
25+
Env nature.Nature
26+
Expect reflect.Kind
27+
ExpectAny bool
28+
Optimize bool
29+
Strict bool
30+
ShortCircuit bool
31+
Profile bool
32+
MaxNodes uint
33+
ConstFns map[string]reflect.Value
34+
Visitors []ast.Visitor
35+
Functions FunctionsTable
36+
Builtins FunctionsTable
37+
Disabled map[string]bool // disabled builtins
38+
NtCache nature.Cache
3939
}
4040

4141
// CreateNew creates new config with default values.
4242
func CreateNew() *Config {
4343
c := &Config{
44-
Optimize: true,
45-
MaxNodes: DefaultMaxNodes,
46-
ConstFns: make(map[string]reflect.Value),
47-
Functions: make(map[string]*builtin.Function),
48-
Builtins: make(map[string]*builtin.Function),
49-
Disabled: make(map[string]bool),
50-
DisableSC: false,
44+
Optimize: true,
45+
ShortCircuit: true,
46+
MaxNodes: DefaultMaxNodes,
47+
ConstFns: make(map[string]reflect.Value),
48+
Functions: make(map[string]*builtin.Function),
49+
Builtins: make(map[string]*builtin.Function),
50+
Disabled: make(map[string]bool),
5151
}
5252
for _, f := range builtin.Builtins {
5353
c.Builtins[f.Name] = f

expr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func Optimize(b bool) Option {
129129
// DisableShortCircuit turns short circuit off.
130130
func DisableShortCircuit() Option {
131131
return func(c *conf.Config) {
132-
c.DisableSC = true
132+
c.ShortCircuit = false
133133
}
134134
}
135135

0 commit comments

Comments
 (0)