Skip to content

cmd/compile: optimize []byte(string1 + string2) #62407

Closed
@mdempsky

Description

@mdempsky

A somewhat common code pattern is []byte(string1 + string2).

Today this gets compiled as two separate steps: concatenating the two strings into a new string, and then copying that string result into a new []byte slice.

But it shouldn't be too much trouble to have the compiler instead recognize these patterns (e.g., recognize an OSTR2BYTES whose operand is an OADDSTR), and optimize accordingly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.SuggestedIssues that may be good for new contributors looking for work to do.compiler/runtimeIssues related to the Go compiler and/or runtime.help wanted

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions