Re:Making a Go program 70% faster with a one character change
by throwaway894345 on Monday November 14, 2022 @04:43PM
(#33601607)
This is true, but it's hard to tell if a pointer escapes or not without actually profiling. That said, I don't think the answer is to avoid pointers, but rather to get comfortable with profiling the escape analyzer. By default, I just stick to the subset of Go which I know won't escape--functions can take pointer parameters, but I'm very careful about returning pointers to data that would otherwise be stack-allocated (even though it's not especially idiomatic, I'll often prefer mutating an `out T` parameter rather than returning a `T` because I know the former will not allocate).
[ Parent
| on HN ]
There are no comments on this comment yet.