Especially when going uphill, it’s so important to keep yourself and the bike moving fluidly to maintain your cadence. Therefore you should opt for longer lines that circle around large obstacles.
On descents like the above mentioned Kodiaq Rock ‘n’ Roll, the key was to choose a line that was faster and would let me roll through a middle section rather than having to pedal again. In curvy sections with lots of turns, it’s important to maintain the flow and reduce braking. Acceleration costs precious energy. Always try to take the most amount of speed with you.