diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2026-01-21 15:48:25 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2026-01-22 11:23:54 +0000 |
| commit | 623df388782dcfe70f4f147cb24197e535f9c89b (patch) | |
| tree | e815bc3ae2e0c315ceccf2cf22d887fea17363b9 /pkg/codesearch/database.go | |
| parent | c1de3220482e317729f83e4e7d32fc30d46ec1e7 (diff) | |
pkg/codesearch: reduce memory consumption a bit more
Use uint32 instead of int for line numbers (2G lines should be enough for everyone).
Reorder fields to remove unnecessary paddings.
Diffstat (limited to 'pkg/codesearch/database.go')
| -rw-r--r-- | pkg/codesearch/database.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/pkg/codesearch/database.go b/pkg/codesearch/database.go index eed853aaf..4abd9b690 100644 --- a/pkg/codesearch/database.go +++ b/pkg/codesearch/database.go @@ -24,9 +24,9 @@ type Database struct { } type Definition struct { - Kind EntityKind `json:"kind,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` + Kind EntityKind `json:"kind,omitempty"` IsStatic bool `json:"is_static,omitempty"` Body LineRange `json:"body,omitempty"` Comment LineRange `json:"comment,omitempty"` @@ -34,16 +34,16 @@ type Definition struct { } type Reference struct { + Name string `json:"name,omitempty"` Kind RefKind `json:"kind,omitempty"` EntityKind EntityKind `json:"entity_kind,omitempty"` - Name string `json:"name,omitempty"` - Line int `json:"line,omitempty"` + Line uint32 `json:"line,omitempty"` } type LineRange struct { File string `json:"file,omitempty"` - StartLine int `json:"start_line,omitempty"` - EndLine int `json:"end_line,omitempty"` + StartLine uint32 `json:"start_line,omitempty"` + EndLine uint32 `json:"end_line,omitempty"` } type EntityKind uint8 @@ -167,9 +167,9 @@ func (db *Database) Merge(other *Database, v *clangtool.Verifier) { } db.mergeCache[id] = def db.reverseCache[def] = id - v.LineRange(def.Body.File, def.Body.StartLine, def.Body.EndLine) + v.LineRange(def.Body.File, int(def.Body.StartLine), int(def.Body.EndLine)) if def.Comment.File != "" { - v.LineRange(def.Comment.File, def.Comment.StartLine, def.Comment.EndLine) + v.LineRange(def.Comment.File, int(def.Comment.StartLine), int(def.Comment.EndLine)) } db.intern(&def.Name) db.intern(&def.Type) |
