4 ms·
Another cool difference between this and Go’s ‘defer’, is that it doesn’t allocate memory on the heap. Go’s ‘defer’ does and it has a small performance cost com
by throw-qqqqq 2y ago
Another cool difference between this and Go’s ‘defer’, is that it doesn’t allocate memory on the heap. Go’s ‘defer’ does and it has a small performance cost compared to just calling the .release() or whatever yourself… shrugs
At least this was the case last I did benchmarks of my Go code. Dno if they changed that.
- klodolph 2y agoDoes go’s defer allocate on the heap? I thought it would only do that if necessary.
- pkaye 2y agoI know they implemented an optimization back in go 1.13. Not sure if that will help. https://github.com/golang/proposal/blob/master/design/34481-opencoded-defers.md https://github.com/golang/proposal/blob/master/design/34481-...