summaryrefslogtreecommitdiff
path: root/include/llvm/Support/Casting.h
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2008-04-16 11:43:47 +0000
committerGabor Greif <ggreif@gmail.com>2008-04-16 11:43:47 +0000
commit917365bef1cfb8493558b76f8e6ceb1e76eba2c5 (patch)
treea143812404865360c2bc8322b16e72c0cc529b60 /include/llvm/Support/Casting.h
parent0d4bdde3270a8ed182a685a580031d6d5d743164 (diff)
downloadllvm-917365bef1cfb8493558b76f8e6ceb1e76eba2c5.tar.gz
llvm-917365bef1cfb8493558b76f8e6ceb1e76eba2c5.tar.bz2
llvm-917365bef1cfb8493558b76f8e6ceb1e76eba2c5.tar.xz
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49787 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/Casting.h')
-rw-r--r--include/llvm/Support/Casting.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h
index 3a68817ce9..61b91343cb 100644
--- a/include/llvm/Support/Casting.h
+++ b/include/llvm/Support/Casting.h
@@ -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;
}