[llvm-commits] [llvm] r49785 - /llvm/branches/ggreif/use-diet/include/llvm/Support/Casting.h

Gabor Greif ggreif at gmail.com
Wed Apr 16 03:37:38 PDT 2008


Author: ggreif
Date: Wed Apr 16 05:37:26 2008
New Revision: 49785

URL: http://llvm.org/viewvc/llvm-project?rev=49785&view=rev
Log:
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

Modified:
    llvm/branches/ggreif/use-diet/include/llvm/Support/Casting.h

Modified: llvm/branches/ggreif/use-diet/include/llvm/Support/Casting.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Support/Casting.h?rev=49785&r1=49784&r2=49785&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Support/Casting.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Support/Casting.h Wed Apr 16 05:37:26 2008
@@ -221,7 +221,7 @@
 //
 
 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 @@
 // 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;
 }
 





More information about the llvm-commits mailing list