From 03f70eadef92f1cdfc09b8767003d64906de46f7 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 18 Jul 2022 15:34:27 +0200 Subject: [PATCH] parse_bitrate: use map for special vals --- src/main.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a84d51281..796db7f2d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -503,8 +503,13 @@ static void *capture_thread(void *arg) } static bool parse_bitrate(char *optarg, long long int *bitrate) { - if (strcmp(optarg, "auto") == 0) { - *bitrate = RATE_AUTO; + map bitrate_spec_map = { + { "auto", RATE_AUTO }, + { "unlimited", RATE_UNLIMITED }, + }; + + if (auto it = bitrate_spec_map.find(optarg); it != bitrate_spec_map.end()) { + *bitrate = it->second; return true; } if (strcmp(optarg, "help") == 0) { @@ -519,10 +524,6 @@ static bool parse_bitrate(char *optarg, long long int *bitrate) { "\n"; return true; } - if (strcmp(optarg, "unlimited") == 0) { - *bitrate = RATE_UNLIMITED; - return true; - } bool force = false, fixed = false; for (int i = 0; i < 2; ++i) { if (optarg[strlen(optarg) - 1] == '!' ||