Skip to content
Snippets Groups Projects
Commit d8a9d7ac authored by Axel Naumann's avatar Axel Naumann
Browse files

Cache the TypeName as index/length into fTrueName; use fTrueName for kOther_t.

parent 28231d3d
No related branches found
No related tags found
No related merge requests found
......@@ -45,11 +45,13 @@ enum EDataType {
class TDataType : public TDictionary {
private:
TypedefInfo_t *fInfo; //pointer to CINT typedef info
TypedefInfo_t *fInfo; //!pointer to CINT typedef info
Int_t fSize; //size of type
EDataType fType; //type id
Long_t fProperty; //The property information for the (potential) underlying class
TString fTrueName; //True name of the (potential) underlying class
TString fTrueName; //Qualified name of the (potential) underlying class, e.g. "MyClass*const*"
Int_t fTypeNameIdx; //Start of class name part of the (potential) underlying class in fTrueName
Int_t fTypeNameLen; //Strlen of class name part of the (potential) underlying class in fTrueName
static TDataType* fgBuiltins[kNumDataTypes]; //Array of builtins
void CheckInfo();
......@@ -65,7 +67,7 @@ public:
virtual ~TDataType();
Int_t Size() const;
Int_t GetType() const { return (Int_t)fType; }
const char *GetTypeName() const;
TString GetTypeName();
const char *GetFullTypeName() const;
const char *AsString(void *buf) const;
Long_t Property() const;
......@@ -75,8 +77,7 @@ public:
static EDataType GetType(const type_info &typeinfo);
static void AddBuiltins(TCollection* types);
ClassDef(TDataType,0) //Basic data type descriptor
ClassDef(TDataType,2) //Basic data type descriptor
};
#endif
......@@ -30,7 +30,8 @@ ClassImp(TDataType)
TDataType* TDataType::fgBuiltins[kNumDataTypes] = {0};
//______________________________________________________________________________
TDataType::TDataType(TypedefInfo_t *info) : TDictionary()
TDataType::TDataType(TypedefInfo_t *info) : TDictionary(),
fTypeNameIdx(-1), fTypeNameLen(0)
{
// Default TDataType ctor. TDataTypes are constructed in TROOT via
// a call to TCling::UpdateListOfTypes().
......@@ -52,7 +53,8 @@ TDataType::TDataType(TypedefInfo_t *info) : TDictionary()
}
//______________________________________________________________________________
TDataType::TDataType(const char *typenam) : fInfo(0), fProperty(kIsFundamental)
TDataType::TDataType(const char *typenam) : fInfo(0), fProperty(kIsFundamental),
fTypeNameIdx(-1), fTypeNameLen(0)
{
// Constructor for basic data types, like "char", "unsigned char", etc.
......@@ -70,8 +72,9 @@ TDataType::TDataType(const TDataType& dt) :
fSize(dt.fSize),
fType(dt.fType),
fProperty(dt.fProperty),
fTrueName(dt.fTrueName)
{
fTrueName(dt.fTrueName),
fTypeNameIdx(dt.fTypeNameIdx), fTypeNameLen(dt.fTypeNameLen)
{
//copy constructor
}
......@@ -87,7 +90,9 @@ TDataType& TDataType::operator=(const TDataType& dt)
fType=dt.fType;
fProperty=dt.fProperty;
fTrueName=dt.fTrueName;
}
fTypeNameIdx=dt.fTypeNameIdx;
fTypeNameLen=dt.fTypeNameLen;
}
return *this;
}
......@@ -134,16 +139,28 @@ const char *TDataType::GetTypeName(EDataType type)
}
//______________________________________________________________________________
const char *TDataType::GetTypeName() const
TString TDataType::GetTypeName()
{
// Get basic type of typedef, e,g.: "class TDirectory*" -> "TDirectory".
// Result needs to be used or copied immediately.
if (fTypeNameLen) {
return fTrueName(fTypeNameIdx, fTypeNameLen);
}
if (fInfo) {
(const_cast<TDataType*>(this))->CheckInfo();
return gInterpreter->TypeName(fTrueName.Data());
TString typeName = gInterpreter->TypeName(fTrueName.Data());
fTypeNameIdx = fTrueName.Index(typeName);
if (fTypeNameIdx == -1) {
Error("GetTypeName", "Cannot find type name %s in true name %s!",
typeName.Data(), fTrueName.Data());
return fName;
}
fTypeNameLen = typeName.Length();
return fTrueName(fTypeNameIdx, fTypeNameLen);
} else {
return fName.Data();
if (fType != kOther_t) return fName.Data();
return fTrueName;
}
}
......@@ -156,7 +173,8 @@ const char *TDataType::GetFullTypeName() const
(const_cast<TDataType*>(this))->CheckInfo();
return fTrueName;
} else {
return fName.Data();
if (fType != kOther_t) return fName;
return fTrueName;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment