diff options
| author | Fuwn <[email protected]> | 2026-02-05 10:39:59 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-05 10:39:59 +0000 |
| commit | 77bbef01943a604fc09e9a422126154988846289 (patch) | |
| tree | 81eb1946475177b82d34e37af48ecfae2d0fa4ca /engine | |
| parent | feat(formatter): Dispatch adapter by file extension for multi-language support (diff) | |
| download | iku-77bbef01943a604fc09e9a422126154988846289.tar.xz iku-77bbef01943a604fc09e9a422126154988846289.zip | |
perf: Reduce allocations and syscalls in formatting pipeline
Diffstat (limited to 'engine')
| -rw-r--r-- | engine/engine.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/engine/engine.go b/engine/engine.go index 7a5399c..15ee568 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -104,13 +104,16 @@ func (e *Engine) Format(events []LineEvent) []string { func (e *Engine) FormatToString(events []LineEvent) string { lines := e.Format(events) - output := strings.Join(lines, "\n") + lines = append(lines, "") - if !strings.HasSuffix(output, "\n") { - output += "\n" - } + return strings.Join(lines, "\n") +} + +func (e *Engine) FormatToBytes(events []LineEvent) []byte { + lines := e.Format(events) + lines = append(lines, "") - return output + return []byte(strings.Join(lines, "\n")) } func (e *Engine) findNextNonComment(events []LineEvent, startIndex int) int { |