Virtual Function Optimization
Ben Phillips
Ben_member at pathlink.com
Sun Apr 30 13:55:46 PDT 2006
How much does D optimize virtual function calls? Lets say you have the following
interface and class (not very useful ones).
interface Collection
{
public int size();
}
class Array : Collection
{
private int[] array;
public:
this() { array.length = 10; }
int size() { return array.length; }
}
Now consider the following statements
Collection c = new Array();
Array a = new Array();
c.size(); // clearly a virtual function call
a.size(); // ?????
Can the compiler deduce that "a.size()" should not be called through the vtable
since the type of "a" is not ambiguous?
More information about the Digitalmars-d
mailing list