From c1de3220482e317729f83e4e7d32fc30d46ec1e7 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 21 Jan 2026 15:21:05 +0100 Subject: pkg/codesearch: reduce memory consumption more Use uint8 enums instead of strings to store entity/reference kind. String is 16 bytes and is slower to work with. --- pkg/codesearch/codesearch.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pkg/codesearch/codesearch.go') diff --git a/pkg/codesearch/codesearch.go b/pkg/codesearch/codesearch.go index 051cad3c5..08018a403 100644 --- a/pkg/codesearch/codesearch.go +++ b/pkg/codesearch/codesearch.go @@ -206,7 +206,7 @@ func (index *Index) FileIndex(file string) ([]Entity, error) { for _, def := range index.db.Definitions { if def.Body.File == file { entities = append(entities, Entity{ - Kind: def.Kind, + Kind: def.Kind.String(), Name: def.Name, }) } @@ -243,7 +243,7 @@ func (index *Index) definitionSource(contextFile, name string, comment, includeL } return &EntityInfo{ File: def.Body.File, - Kind: def.Kind, + Kind: def.Kind.String(), Body: src, }, nil } @@ -299,9 +299,9 @@ func (index *Index) FindReferences(contextFile, name, srcPrefix string, contextL } } results = append(results, ReferenceInfo{ - ReferencingEntityKind: def.Kind, + ReferencingEntityKind: def.Kind.String(), ReferencingEntityName: def.Name, - ReferenceKind: ref.Kind, + ReferenceKind: ref.Kind.String(), SourceFile: def.Body.File, SourceLine: ref.Line, SourceSnippet: snippet, -- cgit mrf-deployment