From: Gabor Greif Date: Wed, 16 Apr 2008 11:43:47 +0000 (+0000) Subject: merge of r49785 (from branches/ggreif/use-diet): pass V to dyn_cast by const referenc... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=917365bef1cfb8493558b76f8e6ceb1e76eba2c5;p=oota-llvm.git Merge ... 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49787 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h index 3a68817ce99..61b91343cb9 100644 --- a/include/llvm/Support/Casting.h +++ b/include/llvm/Support/Casting.h @@ -221,7 +221,7 @@ inline typename cast_retty::ret_type cast_or_null(Y *Val) { // template -inline typename cast_retty::ret_type dyn_cast(Y Val) { +inline typename cast_retty::ret_type dyn_cast(const Y &Val) { return isa(Val) ? cast(Val) : 0; } @@ -229,7 +229,7 @@ inline typename cast_retty::ret_type dyn_cast(Y Val) { // value is accepted. // template -inline typename cast_retty::ret_type dyn_cast_or_null(Y Val) { +inline typename cast_retty::ret_type dyn_cast_or_null(const Y &Val) { return (Val && isa(Val)) ? cast(Val) : 0; }