Backed out dynamic stack array (use fixed size for now)

This commit is contained in:
Phil Nash 2017-09-26 15:55:34 -07:00
parent 2a1f8ae684
commit c1416d55cb

View File

@ -1142,7 +1142,9 @@ namespace detail {
size_t count = 0; size_t count = 0;
}; };
const size_t totalParsers = m_options.size() + m_args.size(); const size_t totalParsers = m_options.size() + m_args.size();
ParserInfo parseInfos[totalParsers]; assert( totalParsers < 512 );
// ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do
ParserInfo parseInfos[512];
size_t i = 0; size_t i = 0;
for( auto const& opt : m_options ) parseInfos[i++].parser = &opt; for( auto const& opt : m_options ) parseInfos[i++].parser = &opt;
for( auto const& arg : m_args ) parseInfos[i++].parser = &arg; for( auto const& arg : m_args ) parseInfos[i++].parser = &arg;
@ -1153,7 +1155,8 @@ namespace detail {
while( result.value().remainingTokens() ) { while( result.value().remainingTokens() ) {
bool tokenParsed = false; bool tokenParsed = false;
for( auto& parseInfo : parseInfos ) { for( size_t i = 0; i < totalParsers; ++i ) {
auto& parseInfo = parseInfos[i];
if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) { if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) {
result = parseInfo.parser->parse(exeName, result.value().remainingTokens()); result = parseInfo.parser->parse(exeName, result.value().remainingTokens());
if (!result) if (!result)