mirror of
https://github.com/jimeh/rbheap.git
synced 2026-02-19 12:56:46 +00:00
Initial hacky version of inspect source command
This commit is contained in:
30
inspect/file.go
Normal file
30
inspect/file.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package inspect
|
||||
|
||||
// NewFile creates a new File.
|
||||
func NewFile(filePath string) *File {
|
||||
return &File{
|
||||
FilePath: filePath,
|
||||
ObjectMap: map[string]*Object{},
|
||||
}
|
||||
}
|
||||
|
||||
// File represents a source file and the lines and objects allocated by them.
|
||||
type File struct {
|
||||
FilePath string
|
||||
ObjectMap map[string]*Object
|
||||
ObjectCount int
|
||||
ByteSize int64
|
||||
MemSize int64
|
||||
}
|
||||
|
||||
// Add adds a object to a File.
|
||||
func (s *File) Add(obj *Object) {
|
||||
_, ok := s.ObjectMap[obj.Address]
|
||||
if !ok && obj.File != "" && obj.Line != 0 {
|
||||
s.ObjectCount++
|
||||
s.ByteSize = s.ByteSize + obj.ByteSize
|
||||
s.MemSize = s.MemSize + obj.MemSize
|
||||
|
||||
s.ObjectMap[obj.Address] = obj
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user