Skip to content

perf: len([]byte(stdout)) allocates unnecessarily in TruncateOutput #65

@jonchun

Description

@jonchun

Summary

TruncateOutput uses len([]byte(stdout)) and len([]byte(stderr)) to get byte lengths. This allocates a full byte-slice copy of each string. In Go, len(s) already returns the byte count of a string without allocation.

Location

output/output.go:29-30

totalStdout := len([]byte(stdout))
totalStderr := len([]byte(stderr))

Suggested Fix

totalStdout := len(stdout)
totalStderr := len(stderr)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority: lowNice to fix - minor improvement

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions