You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Yes, || looks more attractive
Yes, || looks more attractive
It's exactly the same.
Yes, you are right.
Yes, || looks more attractive
It's probably because I'm so used to it😁
Thank you very much!
I'm used to declaring small functions and immediately looking for a reason to exit them, so I mistakenly thought the conditions were different (because of habit, I have a hard time perceiving conditions that lead to additional nesting; I'm a fan of the return statement😁).
So you are suggesting to not use the if shortcut ?
I understand the concept behind what you said but I can hardly believe it's useful in practice (about if shortcut like here).
Though I would be happy to learn I am wrong. Are you able to demonstrate the impact ? (not necessarily with pointer==NULL, I don't care).
It appears that, as expected, comparing with NULL is significantly faster than CheckPointer().
It appears that, as expected, comparing with NULL is significantly faster than CheckPointer().
Thanks. As this topic is about "!" operator, I modified your code to check it.
2025.09.30 07:54:03.239 CCollection::benchmarkNot: 16126 µs, sum = 306697
2025.09.30 07:54:03.242 CCollection::benchmarkNullOrCheck: 2595 µs, sum = 306697
2025.09.30 07:55:01.113 CCollection::benchmarkNullOrCheck: 2436 µs, sum = 9136
2025.09.30 07:55:01.126 CCollection::benchmarkNot: 13135 µs, sum = 9136
2025.09.30 07:55:07.418 CCollection::benchmarkNullOrCheck: 2463 µs, sum = 12135
2025.09.30 07:55:07.434 CCollection::benchmarkNot: 16103 µs, sum = 12135
2025.09.30 07:55:20.724 CCollection::benchmarkNot: 16399 µs, sum = 8854
2025.09.30 07:55:20.726 CCollection::benchmarkNullOrCheck: 2418 µs, sum = 8854
With another view of coding:
With another view of coding:
Thanks for sharing a concrete example of the "no branch" paradigm.
As expected it's not better in this case 😮💨
What's the point of the benchmarkNot_DoubleCheck() ?
As expected it's not better in this case 😮💨
Though, with a little improvement :
2025.09.30 09:18:48.828 CCollection::benchmarkNot 23914 µs, sum = 333795028; Null-Values: 9332204; InstancesCount: 667796
2025.09.30 09:18:48.858 CCollection::benchmarkNot_DoubleCheck 30039 µs, sum = 333795028; Null-Values: 9332204; InstancesCount: 667796
2025.09.30 09:18:48.868 CCollection::benchmarkNullOrCheck 9694 µs, sum = 333795028; Null-Values: 9332204; InstancesCount: 667796
2025.09.30 09:18:48.879 CCollection::benchmarkNullOrCheck_NoBranch 11098 µs, sum = 333795028; Null-Values: 9332204; InstancesCount: 667796
2025.09.30 09:18:48.888 CCollection::benchmarkNullOrCheck_NoBranchAV 9201 µs, sum = 333795028; Null-Values: 9332204; InstancesCount: 667796
PS: Result obtained with AVX512 maximum optimizations.
PS2: There is not really an improvement if you can have dangling pointer (pointer not NULL but invalid).