Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

perf: reuse same gjson parser #3586

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/doc/presexch/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down