6 ms·
I did think of doing that, but from my understanding there is a slight performance hit from `defer`, and there is no other branch it could deadlock - or am I mi
by pojntfx 3y ago
I did think of doing that, but from my understanding there is a slight performance hit from `defer`, and there is no other branch it could deadlock - or am I missing something here? Thanks either way!
Edit: Oh I just saw the addition to your comment - that is exactly what I was thinking of ^^
- philosopher1234 3y agowhat about during a panic?
- pojntfx 3y agoGood point, thanks!
- Patrickmi 3y agoI think there was no performance hit on panic it was memory leak being fixed long time ago
- foldr 3y agoThey mean that the code could deadlock on a panic if the unlock isn't deferred. (At least, in the case where the panic ended up being handled somewhere and the process didn't just exit.)
- kyrra 3y agoDefer overhead was mostly fixed in Go 1.14. From: https://go.dev/doc/go1.14 https://go.dev/doc/go1.14 > This release improves the performance of most uses of defer to incur almost zero overhead compared to calling the deferred function directly. As a result, defer can now be used in performance-critical code without overhead concerns. EDIT: https://github.com/golang/go/issues/14939 https://github.com/golang/go/issues/14939 I believe is the main tracking bug for this.