3 ms·
Right but are those call sites typically monomorphic (i.e. devirtualizable?)
by gok 9y ago
Right but are those call sites typically monomorphic (i.e. devirtualizable?)
- jonhohle 9y agoconst type field in the base class, non-virtual accessor (direct field access can be inlined). Memory vs CPU, the usual trade off.
- euyyn 9y agoIt wouldn't cost memory though, because you free up a slot in the virtual table. No?
- jonhohle 9y agoVirtual table should be one per class. A type field would be once per instance.
- euyyn 9y agoAh, right, static fields in C++ can't be overridden. If they could, they could be implemented by stuffing them in the virtual table and the cost in space would be O(classes) instead of O(instances).
- deleted 9y ago[deleted]
- CJefferson 9y agoOften they become so after inlining.