3 ms·
Didn't you just shift the branch to the calculateDiscount() function?
by Narishma 19d ago
Didn't you just shift the branch to the calculateDiscount() function?
- 1718627440 18d agoNot necessarily. return 1 - user.isPremiumMember * 0.1; would also cut it.
- lscharen 17d agoNo, because the point is that the branch version does not touch "total" when the branch is taken, but the non-branch version will always multiply "total" by something.