The compiler (gc) has come a long way, however the inliner is sometimes lacking, for example any function with a for-loop no matter how simple it is, won't get inlined so we either have to use a goto loop instead (which is used few times in the runtime) or just have a one big ugly function.
My proposal is to add a go:inline directive that will force inlining, even if it's just for non-exported functions.
This will help make a lot of code much cleaner and allows separation of big functions that can't be currently inlined.
If the proposal is accepted, I'd like to work on it.
Another semi-common example:
func (xx *XXHash64) WriteString(s string) (int, error) {
if len(s) == 0 {
return 0, nil
}
return xx.Write([]byte(s))
}
// cannot inline (*XXHash64).WriteString: non-leaf method
Related: #17566 #14768
@dr2chase @josharian @randall77 @mvdan
The compiler (gc) has come a long way, however the inliner is sometimes lacking, for example any function with a
for-loopno matter how simple it is, won't get inlined so we either have to use agotoloop instead (which is used few times in the runtime) or just have a one big ugly function.My proposal is to add a
go:inlinedirective that will force inlining, even if it's just for non-exported functions.This will help make a lot of code much cleaner and allows separation of big functions that can't be currently inlined.
If the proposal is accepted, I'd like to work on it.Another semi-common example:
Related: #17566 #14768
@dr2chase @josharian @randall77 @mvdan