Skip to content

cmd/compile: readonly analysis of functions accepting []byte arguments #29810

@josharian

Description

@josharian

In #29802, @rillig observes that encoding/hex.Decode only reads from its []byte argument. (In particular, it calls len and reads bytes at particular indices.) We could teach the compiler that for such arguments, we can avoid an alloc+copy when passing an argument converted from a string, the way we do with map lookups.

The obvious question is how often this occurs, and whether it justifies the cost (implementation, maintenance, code complexity, execution time).

I thought that we already had an issue for this, but I can't find it.

cc @martisch @mvdan @randall77

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performance

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions