x/tools/internal/refactor/inline: allow conversions to be considered duplicable #67589
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
A subtask of #63352.
At the moment, inliner does not consider type conversions as duplicable operations.
For example, inlining a function
f
generates this code:
Instead, inliner should consider some conversions (those that do not change semantics or involve additional allocations) to be duplicable:
One way to implement this is by changing
duplicable
function to cover the type conversion cases, which are parsed as*ast.CallExpr
with theFun
field being one of*ast.Ident
,*ast.ArrayType
,*ast.StructType
,*ast.FuncType
,*ast.InterfaceType
,*ast.MapType
, or*ast.ChanType
.As per spec,
string([]byte)
and[]byte(string)
conversions may involve additional allocations and should not be considered duplicable:The text was updated successfully, but these errors were encountered: