Skip to content

Commit

Permalink
perf(pipe): test without copy
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienaury committed Sep 19, 2024
1 parent 85dc11d commit 05cde85
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
2 changes: 0 additions & 2 deletions pkg/jsonline/jsonline.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ func (s Sink) ProcessDictionary(dictionary model.Entry) error {
// JSONToDictionary return a model.Dictionary from a jsonline
func JSONToDictionary(jsonline []byte) (model.Dictionary, error) {
dict := model.NewDictionary()

err := dict.UnmarshalJSON(jsonline)

return model.CleanDictionary(dict), err
}

Expand Down
10 changes: 0 additions & 10 deletions pkg/model/ordered_dict.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,14 @@ func CleanTypes(inter interface{}) interface{} {
}
return tab
case json.Number:

resFloat64, err := typedInter.Float64()
if err == nil {
return resFloat64
}

return typedInter.String()

case uint64:
res := float64(typedInter)
return res

case int64:
res := float64(typedInter)
return res
Expand Down Expand Up @@ -259,29 +255,23 @@ func UnorderedTypes(inter interface{}) interface{} {
return cleanmap
case []interface{}:
tab := []Entry{}

for _, item := range typedInter {
tab = append(tab, UnorderedTypes(item))
}

return tab

case []Dictionary:
tab := []Entry{}

for _, item := range typedInter {
tab = append(tab, UnorderedTypes(item))
}

return tab

case []Entry:
tab := []Entry{}

for _, item := range typedInter {
tab = append(tab, UnorderedTypes(item))
}

return tab

default:
Expand Down
5 changes: 3 additions & 2 deletions pkg/pipe/pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func (me MaskEngine) MaskContext(e model.Dictionary, key string, context ...mode
var result []model.Entry
input := []model.Dictionary{}

copy := model.CopyDictionary(e)
// copy := model.CopyDictionary(e)
copy := e

value, ok := e.GetValue(key)
if !ok || value == nil {
Expand Down Expand Up @@ -99,7 +100,7 @@ func (me MaskEngine) MaskContext(e model.Dictionary, key string, context ...mode
over.MDC().Set("path", savePath)
over.MDC().Set("context", saveContext)
if err != nil {
return model.NewDictionary(), err
return copy, err
}
for _, dict := range result {
if len(me.injectParent) > 0 {
Expand Down

0 comments on commit 05cde85

Please sign in to comment.