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
In #29802, @rillig observes that encoding/hex.Decode only reads from its
[]byteargument. (In particular, it callslenand 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