merge of r49785 (from branches/ggreif/use-diet): pass V to dyn_cast by const reference, this avoids copy-constructing and destructing all the time. especially important if these constructors are not accessible

llvm-svn: 49787
This commit is contained in:
Gabor Greif 2008-04-16 11:43:47 +00:00
parent 6d05ce493b
commit 32b4942a0a

View File

@ -221,7 +221,7 @@ inline typename cast_retty<X, Y*>::ret_type cast_or_null(Y *Val) {
//
template <class X, class Y>
inline typename cast_retty<X, Y>::ret_type dyn_cast(Y Val) {
inline typename cast_retty<X, Y>::ret_type dyn_cast(const Y &Val) {
return isa<X>(Val) ? cast<X, Y>(Val) : 0;
}
@ -229,7 +229,7 @@ inline typename cast_retty<X, Y>::ret_type dyn_cast(Y Val) {
// value is accepted.
//
template <class X, class Y>
inline typename cast_retty<X, Y>::ret_type dyn_cast_or_null(Y Val) {
inline typename cast_retty<X, Y>::ret_type dyn_cast_or_null(const Y &Val) {
return (Val && isa<X>(Val)) ? cast<X, Y>(Val) : 0;
}