From 24b98616c4425a8ef380d2d5fef00f82af9df985 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 29 Aug 2014 17:04:49 -0400
Subject: [PATCH] Ensure that safe_as_a can have no performance overhead in a
release build
gcc/
* is-a.h (safe_as_a): Eliminate the conditional from the
!defined(ENABLE_CHECKING) case, to ensure there can be no
performance degradation of the release build.
---
gcc/is-a.h | 4 ++++
1 file changed, 4 insertions(+)
@@ -200,6 +200,7 @@ template <typename T, typename U>
inline T
safe_as_a (U *p)
{
+#ifdef ENABLE_CHECKING
if (p)
{
gcc_checking_assert (is_a <T> (p));
@@ -207,6 +208,9 @@ safe_as_a (U *p)
}
else
return NULL;
+#else
+ return is_a_helper <T>::cast (p);
+#endif
}
/* A generic checked conversion from a base type U to a derived type T. See
--
1.8.5.3