Skip to content

Commit

Permalink
classes store pointer to ClassMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
zdyj3170101136 committed Aug 1, 2023
1 parent a526cc1 commit 7151b79
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 89 deletions.
2 changes: 1 addition & 1 deletion parser/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (c *CheckpointEvent) Parse(r reader.Reader, classes ClassMap, cpools PoolMa
results[i] = &threads[i]
}
case "jdk.types.StackTrace":
var classStackFrames ClassMetadata
var classStackFrames *ClassMetadata
for _, class := range classes {
if class.Name == "jdk.types.StackFrame" {
classStackFrames = class
Expand Down
9 changes: 5 additions & 4 deletions parser/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type CPool struct {
Pool map[int]ParseResolvable
resolved bool
}
type ClassMap map[int]ClassMetadata
type ClassMap map[int]*ClassMetadata
type PoolMap map[int]*CPool

type Chunk struct {
Expand Down Expand Up @@ -42,7 +42,7 @@ type Chunk struct {
}

type ChunkParseOptions struct {
CPoolProcessor func(meta ClassMetadata, cpool *CPool)
CPoolProcessor func(meta *ClassMetadata, cpool *CPool)
}

func (c *Chunk) Parse(r io.Reader, options *ChunkParseOptions) (err error) {
Expand Down Expand Up @@ -218,8 +218,9 @@ func (c *Chunk) buildClasses(metadata MetadataEvent) ClassMap {
return &c.nativeLibrary
},
}
classes := make(map[int]ClassMetadata, len(metadata.Root.Metadata.Classes))
for _, class := range metadata.Root.Metadata.Classes {
classes := make(map[int]*ClassMetadata, len(metadata.Root.Metadata.Classes))
for i := range metadata.Root.Metadata.Classes {
class := &metadata.Root.Metadata.Classes[i]
var numConstants int
for _, field := range class.Fields {
if field.ConstantPool {
Expand Down
Loading

0 comments on commit 7151b79

Please sign in to comment.