-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.Performance
Milestone
Description
This method always allocates because it returns a slice that escapes to the return value.
If the method were inlineable, the compiler may prove in some cases that the return value does not escape and can be stack allocated.
Currently, the method is a cost of 222; way over the budget of 80.
One attempt to optimize this was:
func (ip Addr) AsSlice() []byte {
ret := ip.As16()
switch ip.z {
case z0:
return nil
case z4:
return ret[12:]
default:
return ret[:]
}
}
However, this is a function cost of 83. Just slightly over the budget.
OneOfOne, mateusz834 and mvdan
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.Performance