Skip to content

Commit 67dd397

Browse files
committed
perf: reduce unnecessary instance creation of Type()
1 parent 22a4d16 commit 67dd397

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

dsl/types/json.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ type Array interface {
149149

150150
// NewArray creates Array instance
151151
func NewArray(value []Value, argType Type) Array {
152-
return &arrayT{value: value, argType: argType}
152+
return &arrayT{value: value, typ: NewArrayType(argType)}
153153
}
154154

155155
type arrayT struct {
156-
value []Value
157-
argType Type
156+
value []Value
157+
typ Type
158158
}
159159

160160
func (v *arrayT) Value() []Value {
@@ -170,7 +170,7 @@ func (v *arrayT) Eval(context.Context) (val Value, rollback func(), err error) {
170170
}
171171

172172
func (v *arrayT) Type() Type {
173-
return NewArrayType(v.argType)
173+
return v.typ
174174
}
175175

176176
// ================ Object ================
@@ -187,12 +187,12 @@ type Object interface {
187187

188188
// NewObject creates Object instance
189189
func NewObject(value map[string]Value, argType Type) Object {
190-
return &objectT{value: value, argType: argType}
190+
return &objectT{value: value, typ: NewObjectType(argType)}
191191
}
192192

193193
type objectT struct {
194-
value map[string]Value
195-
argType Type
194+
value map[string]Value
195+
typ Type
196196
}
197197

198198
func (v *objectT) Value() map[string]Value {
@@ -208,5 +208,5 @@ func (v *objectT) Eval(context.Context) (val Value, rollback func(), err error)
208208
}
209209

210210
func (v *objectT) Type() Type {
211-
return NewObjectType(v.argType)
211+
return v.typ
212212
}

0 commit comments

Comments
 (0)