Improve performance of lCheckTypeEquality()
We don't need to explicitly create the non-const Types to do type comparison when ignoring const-ness in the check. We can also save some unnecessary dynamic memory allocation by keeping strings returned from GetStructName() as references to strings. This gives another 10% on front-end perf on that big program.
This commit is contained in:
15
type.cpp
15
type.cpp
@@ -3106,13 +3106,8 @@ lCheckTypeEquality(const Type *a, const Type *b, bool ignoreConst) {
|
|||||||
if (a == NULL || b == NULL)
|
if (a == NULL || b == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (ignoreConst == true) {
|
if (ignoreConst == false &&
|
||||||
if (CastType<FunctionType>(a) == NULL)
|
a->IsConstType() != b->IsConstType())
|
||||||
a = a->GetAsNonConstType();
|
|
||||||
if (CastType<FunctionType>(b) == NULL)
|
|
||||||
b = b->GetAsNonConstType();
|
|
||||||
}
|
|
||||||
else if (a->IsConstType() != b->IsConstType())
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const AtomicType *ata = CastType<AtomicType>(a);
|
const AtomicType *ata = CastType<AtomicType>(a);
|
||||||
@@ -3156,8 +3151,10 @@ lCheckTypeEquality(const Type *a, const Type *b, bool ignoreConst) {
|
|||||||
if (a->GetVariability() != b->GetVariability())
|
if (a->GetVariability() != b->GetVariability())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string namea = sta ? sta->GetStructName() : usta->GetStructName();
|
const std::string &namea = sta ? sta->GetStructName() :
|
||||||
std::string nameb = stb ? stb->GetStructName() : ustb->GetStructName();
|
usta->GetStructName();
|
||||||
|
const std::string &nameb = stb ? stb->GetStructName() :
|
||||||
|
ustb->GetStructName();
|
||||||
return (namea == nameb);
|
return (namea == nameb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user