Well, it’s actually only a displacement of sexual energy. It’s a mechanism of defence that Freud discovered (I think there are more up to date terms today).
I remember sometime I used to get me horny for a girl (a girl I know I can see Hahaha) and crank up my libido high. Once it was done, I was setting a moment to see her and let my lust guide my work until the moment I see her… Which means more focus, more productivity and, for example at 7h30, I would take a shower, she’d be there at 8 and we had sex for 1-2 hours and then she goes back to her place, I go sleep and boom! Wake up early next day to work yet again. I was studying like 10-12 hours per day in that time.
I saw like three different girls in that time. Had sex once a week, max 2, no masturbation so my libido stay high!