From e1bc010bd139e45ba9360c8333ed96c4f1066cbd Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 4 May 2012 13:41:47 -0700 Subject: [PATCH] More reduction of dynamic allocations in lDoTypeConv() --- expr.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/expr.cpp b/expr.cpp index 47111936..8236e8e4 100644 --- a/expr.cpp +++ b/expr.cpp @@ -279,10 +279,10 @@ lDoTypeConv(const Type *fromType, const Type *toType, Expr **expr, const Type *eltType = fromArrayType->GetElementType(); if (toPointerType->GetBaseType()->IsConstType()) eltType = eltType->GetAsConstType(); - if (Type::Equal(toPointerType, - new PointerType(eltType, - toPointerType->GetVariability(), - toPointerType->IsConstType()))) + + PointerType pt(eltType, toPointerType->GetVariability(), + toPointerType->IsConstType()); + if (Type::Equal(toPointerType, &pt)) goto typecast_ok; else { if (!failureOk) @@ -392,7 +392,9 @@ lDoTypeConv(const Type *fromType, const Type *toType, Expr **expr, // Convert from type T -> const T; just return a TypeCast expr, which // can handle this - if (Type::Equal(toType, fromType->GetAsConstType())) + if (Type::EqualIgnoringConst(toType, fromType) && + toType->IsConstType() == true && + fromType->IsConstType() == false) goto typecast_ok; if (CastType(fromType)) {