Skip to content

Commit

Permalink
types: batch allocate StackFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
zdyj3170101136 committed Aug 1, 2023
1 parent e587646 commit 2aa0b33
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion parser/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,13 @@ func parseFields(r reader.Reader, classes ClassMap, cpools PoolMap, class ClassM
}
}
} else if f.Dimension == 1 {
n, err := r.VarInt()
offset := r.Offset()
err := cb(r, "len", nil)
if err != nil {
return fmt.Errorf("failed to parse %s: unable to read array length: %w", class.Name, err)
}
_, _ = r.SeekStart(int64(offset))
n, _ := r.VarInt() // this must successfult
// TODO: assert n is small enough
for i := 0; i < int(n); i++ {
var p ParseResolvable
Expand Down Expand Up @@ -882,6 +885,12 @@ func (st *StackTrace) parseField(r reader.Reader, name string, p ParseResolvable
return err
}
st.Frames = append(st.Frames, sf)
case "len":
frameLen, err := r.VarInt()
if err != nil {
return err
}
st.Frames = make([]*StackFrame, 0, frameLen)
}
return err
}
Expand Down

0 comments on commit 2aa0b33

Please sign in to comment.