From aa6e2ffbd384b83b3bdb27e10d89a0f142bc0b72 Mon Sep 17 00:00:00 2001 From: Stas D Date: Mon, 15 May 2023 13:06:09 +0200 Subject: [PATCH] perf: reuse same parser Signed-off-by: Stas D --- pkg/doc/presexch/definition.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/doc/presexch/definition.go b/pkg/doc/presexch/definition.go index 84470227d..cf29cd502 100644 --- a/pkg/doc/presexch/definition.go +++ b/pkg/doc/presexch/definition.go @@ -1005,6 +1005,8 @@ func getLimitedDisclosures(constraints *Constraints, displaySrc []byte, credenti var limitedDisclosures []*common.DisclosureClaim + parsedGJSON := gjson.ParseBytes(credentialSrc) + for _, f := range constraints.Fields { jPaths, err := getJSONPaths(f.Path, displaySrc) if err != nil { @@ -1026,7 +1028,7 @@ func getLimitedDisclosures(constraints *Constraints, displaySrc []byte, credenti key = pathParts[len(pathParts)-1] } - parentObj, ok := gjson.GetBytes(credentialSrc, parentPath).Value().(map[string]interface{}) + parentObj, ok := parsedGJSON.Get(parentPath).Value().(map[string]interface{}) if !ok { // no selective disclosures at this level, so nothing to add to limited disclosures continue