From dcb291fa4d648af92cf1c3ea1e204f7036d8df4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Mon, 6 Jun 2016 09:00:52 +0200 Subject: [PATCH] Remove magic numbers. Prefer named indices in the integer lists when they are used in favour of mnemonics. --- .../eclipse/EclipseState/IOConfig/IOConfig.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp b/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp index 9d53fef74..d4dae73e6 100644 --- a/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp +++ b/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp @@ -108,8 +108,11 @@ namespace Opm { /* mnemonics, but without basic and freq. Effectively ignored */ if( !ints ) return {}; - if( items.size() >= 1 ) - basic = std::stoul( items[ 0 ] ); + const int BASIC_index = 0; + const int FREQ_index = 5; + + if( items.size() > BASIC_index ) + basic = std::stoul( items[ BASIC_index ] ); // Peculiar special case in eclipse, - not documented // This ignore of basic = 0 for the integer mnemonics case @@ -118,8 +121,8 @@ namespace Opm { // we are missing here. if( 0 == basic ) return {}; - if( items.size() >= 6 ) // if frequency is set - freq = std::stoul( items[ 5 ] ); + if( items.size() > FREQ_index ) // if frequency is set + freq = std::stoul( items[ FREQ_index ] ); return restartConfig( step, basic, freq ); } @@ -160,9 +163,11 @@ namespace Opm { * mnemonics. Restart integer switch is integer control nr 7 */ - if( items.size() < 7 ) return {}; + const int RESTART_index = 6; - return restartConfig( std::stoul( items[ 6 ] ) ); + if( items.size() <= RESTART_index ) return {}; + + return restartConfig( std::stoul( items[ RESTART_index ] ) ); } DynamicState< IOConfig::restartConfig > IOConfig::rstconf(