+ 1

Efficiency Question

Which of these, if they were to be called regularly, would be more efficient? Pseudo code: If num != 1: num = 1 Or........ num = 1 My question i guess is it faster to confirm that the number is a 1 or faster to just assign it anyway and move past it?

25th Mar 2021, 5:49 PM
LordHill
LordHill - avatar
3 Antworten
+ 8
If you'd decide to simply assign it and move on, it'd probably benefit you to note the repercussions ahead of time, depending on what you'd be doing, etc.
25th Mar 2021, 5:51 PM
Fox
Fox - avatar
+ 1
In first an extra check if made in if condition. So definitely assignment faster than check + assignment.
1st Apr 2021, 9:45 PM
patilkrunal
patilkrunal - avatar
0
What the benefit of condition there..? Anyways always num=1
25th Mar 2021, 9:01 PM
Jayakrishna 🇮🇳