This is mostly a performance optimization. We notice that we always attempt to detach the condition, regardless of whether we've attached it to begin with. We can use that to our advantage, in that during the initial iteration to check if something has triggered, we can also attach at the same time. This saves us from having to iterate over the wait set again later on. There is a downside here in that we may end up attaching things that we didn't need, but we also only do that up until something is ready. So this is probably a performance win in the usual cases.
This is mostly a performance optimization. We notice that we always attempt to detach the condition, regardless of whether we've attached it to begin with. We can use that to our advantage, in that during the initial iteration to check if something has triggered, we can also attach at the same time. This saves us from having to iterate over the wait set again later on. There is a downside here in that we may end up attaching things that we didn't need, but we also only do that up until something is ready. So this is probably a performance win in the usual cases.