From 3a6af0d8cc27d897c296908780bd91373c6dc4b5 Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Tue, 14 Jan 2025 10:38:54 +0100 Subject: [PATCH] Simplify parser --- cpp/s2p/s2p_parser.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/cpp/s2p/s2p_parser.cpp b/cpp/s2p/s2p_parser.cpp index 9c5026dc..83d323b4 100644 --- a/cpp/s2p/s2p_parser.cpp +++ b/cpp/s2p/s2p_parser.cpp @@ -290,16 +290,9 @@ vector S2pParser::ConvertLegacyOptions(const span &initial_args) // -hd|-HD -> -h // -idn:u|-hdn:u -> -i|-h n:u vector args; - for (const string arg : initial_args) { - int start_of_ids = -1; - for (int i = 0; i < static_cast(arg.length()); ++i) { - if (isdigit(arg[i])) { - start_of_ids = i; - break; - } - } - - const string &ids = start_of_ids != -1 ? arg.substr(start_of_ids) : ""; + for (const string &arg : initial_args) { + const size_t start_of_ids = arg.find_first_of("0123456789"); + const string &ids = (start_of_ids != string::npos) ? arg.substr(start_of_ids) : ""; const string &arg_lower = ToLower(arg); if (arg_lower.starts_with("-h") || arg_lower.starts_with("-i")) {