5 ms·
You can make register_device() an inline function that just calls a do_register_device() private function without the badge. That way you don't have to pay for
by dearrifling 7y ago
You can make register_device() an inline function that just calls a do_register_device() private function without the badge. That way you don't have to pay for the empty class.
- jcl 7y agoI'm not sure I follow... The motivation for Badge is to have methods on VFS that only Device can call, without exposing VFS's internals to Device. Without Badge, what prevents non-Device functions from calling register_device()?
- taylorconor 7y agoI guess the inline function would require a Badge and the private member function would not. So an inline constructed but never used Badge is even more likely to be completely optimized away
- dearrifling 7y agoExactly. https://godbolt.org/z/j-THTX https://godbolt.org/z/j-THTX