diff options
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/libsupc++/dyncast.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libstdc++-v3/libsupc++/dyncast.cc b/libstdc++-v3/libsupc++/dyncast.cc index 853c911..616e4c0 100644 --- a/libstdc++-v3/libsupc++/dyncast.cc +++ b/libstdc++-v3/libsupc++/dyncast.cc @@ -71,6 +71,12 @@ __dynamic_cast (const void *src_ptr, // object started from if (whole_prefix->whole_type != whole_type) return NULL; + // Avoid virtual function call in the simple success case. + if (src2dst >= 0 + && src2dst == -prefix->whole_object + && *whole_type == *dst_type) + return const_cast <void *> (whole_ptr); + whole_type->__do_dyncast (src2dst, __class_type_info::__contained_public, dst_type, whole_ptr, src_type, src_ptr, result); if (!result.dst_ptr) |