[ROOT] Virtual function tables in small classes

From: George Heintzelman (gah@bnl.gov)
Date: Mon Apr 03 2000 - 23:57:25 MEST


Hi,

I recently sent a note to this list regarding making a macro (which I 
called ClassDefDoc()), for the purpose of allowing one to avoid the 
virtual function table size overhead in small objects.

It happened that I noticed that this overhead is there in two ROOT 
objects that I would think should be commonly used, which may in places 
add significantly to certain overheads (in particular, array sizes and 
argument passing). These are TString and TDatime.

Both classes are data classes, not really intended to be derived from 
(I understand that TString used to be derived from, but TStringLong has 
been obsoleted). Neither has any virtual functions except for the ones 
defined by the ClassDef macro; and both have a data field which is one 
byte long. This would make them ideal for being able to be passed by 
value, used in arrays, and so forth, except that they do define virtual 
functions -- and so the size of the objects is 8 bytes instead of 4 (on 
my Linux boxes, probably similar results elsewhere).

As far as I can tell, there's no compelling need for this inefficiency; I've successfully removed it from a couple of my classes, using my ClassDefDoc() macro, and linked those classes with CINT, read and written them to ROOT files (though not polymorphically, of course), and had no trouble.

Is there any chance these ROOT classes can be fixed this way as well?

George Heintzelman
gah@bnl.gov



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:22 MET