Skip to content

Commit 6fc2e48

Browse files
committed
fix: eachkey allocation
1 parent a6f867e commit 6fc2e48

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

parser.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,12 @@ func EachKey(data []byte, cb func(int, []byte, ValueType, error), paths ...[]str
499499
case '[':
500500
var ok bool
501501
arrIdxFlags := make(map[int]struct{})
502-
pIdxFlags := make([]bool, len(paths))
502+
503+
pIdxFlags := make([]bool, stackArraySize)[:]
504+
if len(paths) > cap(pIdxFlags) {
505+
pIdxFlags = make([]bool, len(paths))[:]
506+
}
507+
pIdxFlags = pIdxFlags[0:len(paths)]
503508

504509
if level < 0 {
505510
cb(-1, nil, Unknown, MalformedJsonError)

0 commit comments

Comments
 (0)