From 162ea1a49aa4b8f6c41c77ee5d533a63ec2e89ba Mon Sep 17 00:00:00 2001 From: Eirik Byrkjeflot Anonsen Date: Mon, 4 Apr 2016 18:29:07 +0200 Subject: [PATCH] Replace two dynamic_casts with static_casts This eliminates two uses of RTTI in Catch. --- include/internal/catch_test_case_tracker.hpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/include/internal/catch_test_case_tracker.hpp b/include/internal/catch_test_case_tracker.hpp index 505c3ab8..44529206 100644 --- a/include/internal/catch_test_case_tracker.hpp +++ b/include/internal/catch_test_case_tracker.hpp @@ -234,10 +234,8 @@ namespace TestCaseTracking { SectionTracker* section = CATCH_NULL; ITracker& currentTracker = ctx.currentTracker(); - if( ITracker* childTracker = currentTracker.findChild( name ) ) { - section = dynamic_cast( childTracker ); - assert( section ); - } + if( ITracker* childTracker = currentTracker.findChild( name ) ) + section = static_cast( childTracker ); else { section = new SectionTracker( name, ctx, ¤tTracker ); currentTracker.addChild( section ); @@ -265,10 +263,8 @@ namespace TestCaseTracking { IndexTracker* tracker = CATCH_NULL; ITracker& currentTracker = ctx.currentTracker(); - if( ITracker* childTracker = currentTracker.findChild( name ) ) { - tracker = dynamic_cast( childTracker ); - assert( tracker ); - } + if( ITracker* childTracker = currentTracker.findChild( name ) ) + tracker = static_cast( childTracker ); else { tracker = new IndexTracker( name, ctx, ¤tTracker, size ); currentTracker.addChild( tracker );