From 13b1a22102038fc06f7bbcc3e589bbfe07ba0507 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Fri, 19 Jun 2026 22:47:12 +0100 Subject: [PATCH] perf(parser): denser symbols-only skeleton fallback The fallback skeleton (c/cpp/elixir/html/vue) is not valid source, so the '// ' comment framing and '(line N)' wording just cost tokens. Use a compact 'kind name :line' form. ~15-25% fewer tokens on fallback skeletons; output stays accurate. --- internal/parser/skeleton.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/internal/parser/skeleton.go b/internal/parser/skeleton.go index c37540f..d37b14a 100644 --- a/internal/parser/skeleton.go +++ b/internal/parser/skeleton.go @@ -40,17 +40,19 @@ func SkeletonFile(ctx context.Context, reg *Registry, filename string, content [ } } -// renderSymbolsOnly renders a simple symbol list (fallback for unsupported languages). -// It deliberately does not fabricate " { ... }" output: the raw start -// line plus a guessed brace is wrong for brace-less languages (e.g. Elixir's "def f do", -// HTML) and only wastes tokens. The symbol list (kind, name, line, doc) is accurate. +// renderSymbolsOnly renders a compact symbol list (fallback for unsupported +// languages). It deliberately does not fabricate " { ... }" output: +// the raw start line plus a guessed brace is wrong for brace-less languages (e.g. +// Elixir's "def f do", HTML) and only wastes tokens. The output is not valid +// source, so it drops "// " comment framing and uses a dense "kind name :line" +// form to minimise tokens. The symbol list (kind, name, line, doc) is accurate. func renderSymbolsOnly(syms []protocol.Symbol, lang protocol.Language) string { var sb strings.Builder - fmt.Fprintf(&sb, "// skeleton unavailable for %s — symbol list only\n", lang) + fmt.Fprintf(&sb, "symbols only (no skeleton for %s):\n", lang) for _, s := range syms { - fmt.Fprintf(&sb, "// %s %s (line %d)\n", s.Kind, s.Name, s.Location.Line) + fmt.Fprintf(&sb, "%s %s :%d\n", s.Kind, s.Name, s.Location.Line) if s.Doc != "" { - fmt.Fprintf(&sb, "// doc: %s\n", s.Doc) + fmt.Fprintf(&sb, " doc: %s\n", s.Doc) } } return sb.String()