refactor: apply for_each to remove repeated code
author백종민/Tizen Platform Lab(SR)/삼성전자 <jm0829.baek@samsung.com>
Tue, 17 Oct 2023 05:16:47 +0000 (14:16 +0900)
committer백종민/Tizen Platform Lab(SR)/삼성전자 <jm0829.baek@samsung.com>
Tue, 17 Oct 2023 05:16:47 +0000 (14:16 +0900)
src/esplusplayer/src/esplayer.cpp

index 779137b..fc6e940 100644 (file)
@@ -3007,22 +3007,20 @@ void EsPlayer::InitValuesFromIni_() {
 namespace es_conf {
 
 void LoadIniProperty(const Json::Value& root) {
+  // clang-format off
+  std::vector<std::string> booleanKeys {
+      "generate_dot",
+      "force_sw_audio_codec",
+      "force_sw_video_codec",
+      "fallback_to_sw_audio_codec",
+      "fallback_to_sw_video_codec"
+  };
+  // clang-format on
   gst_util::GstInit(root);
-  std::string key = "generate_dot";
-  es_conf::ini_property[key] = root.get(key, "").asBool();
-  LOG_DEBUG("[%s] : [%d]", key.c_str(), es_conf::ini_property[key]);
-  key = "force_sw_audio_codec";
-  es_conf::ini_property[key] = root.get(key, "").asBool();
-  LOG_DEBUG("[%s] : [%d]", key.c_str(), es_conf::ini_property[key]);
-  key = "force_sw_video_codec";
-  es_conf::ini_property[key] = root.get(key, "").asBool();
-  LOG_DEBUG("[%s] : [%d]", key.c_str(), es_conf::ini_property[key]);
-  key = "fallback_to_sw_audio_codec";
-  es_conf::ini_property[key] = root.get(key, "").asBool();
-  LOG_DEBUG("[%s] : [%d]", key.c_str(), es_conf::ini_property[key]);
-  key = "fallback_to_sw_video_codec";
-  es_conf::ini_property[key] = root.get(key, "").asBool();
-  LOG_DEBUG("[%s] : [%d]", key.c_str(), es_conf::ini_property[key]);
+  std::for_each(booleanKeys.begin(), booleanKeys.end(), [&](const auto& key) {
+    es_conf::ini_property[key] = root.get(key, "").asBool();
+    LOG_DEBUG("[%s] : [%d]", key.c_str(), es_conf::ini_property[key]);
+  });
 }
 
 bool LoadIniFile() {