Description
A significant fraction of init time in some programs
(notably the go command but surely others) is spent
executing lines like:
var ErrMyError = errors.New("my error")
This is such a widespread use that it may well be
worth recognizing in the compiler and turning into
static data, so that it can be laid out in the data section,
discarded by the linker as appropriate, and have no
link-time overhead at all.
The specific pattern would be exactly the above
(var foo = errors.New(constString)
) and it would turn into
var foo = error(&errors.errorString{s: constString})
This would require that the compiler be able to lay out an
implicit interface conversion in the data section as well.
If that can't be done in general, it would suffice to special
case the "errors.errorString to error" conversion.
If this sounds like fun to someone familiar with the
compiler, please have a look. Thanks.