[vlc-devel] [PATCH 4/5] macosx: simplify and cache result of is-main check

Lyndon Brown jnqnfe at gmail.com
Thu Sep 24 01:11:09 CEST 2020


From: Lyndon Brown <jnqnfe at gmail.com>
Date: Tue, 9 Apr 2019 01:11:28 +0100
Subject: macosx: simplify and cache result of is-main check


diff --git a/modules/gui/macosx/preferences/prefs.m b/modules/gui/macosx/preferences/prefs.m
index a8847e7189..60d7aef2a9 100644
--- a/modules/gui/macosx/preferences/prefs.m
+++ b/modules/gui/macosx/preferences/prefs.m
@@ -492,10 +492,11 @@
         unsigned int confsize;
 
         module_t * p_module = modules[i];
+        bool mod_is_main = module_is_main(p_module);
 
         /* Exclude empty plugins (submodules don't have config */
         /* options, they are stored in the parent module) */
-        if (module_is_main(p_module)) {
+        if (mod_is_main) {
             pluginItem = self;
             _configItems = module_config_get(p_module, &confsize);
             _configSize = confsize;
@@ -507,6 +508,7 @@
 
         for (unsigned int j = 0; j < confsize; j++) {
             int configType = p_configs[j].i_type;
+
             if (configType == CONFIG_CATEGORY) {
                 categoryItem = [self itemRepresentingCategory:(int)p_configs[j].value.i];
                 if (!categoryItem) {
@@ -514,8 +516,10 @@
                     if (categoryItem)
                         [[self children] addObject:categoryItem];
                 }
+                continue;
             }
-            else if (configType == CONFIG_SUBCATEGORY) {
+
+            if (configType == CONFIG_SUBCATEGORY) {
                 lastsubcat = (int)p_configs[j].value.i;
                 if (categoryItem && ![self isSubCategoryGeneral:lastsubcat]) {
                     subCategoryItem = [categoryItem itemRepresentingSubCategory:lastsubcat];
@@ -525,16 +529,20 @@
                             [[categoryItem children] addObject:subCategoryItem];
                     }
                 }
+                continue;
             }
 
-            if (module_is_main(p_module) && (CONFIG_ITEM(configType) || configType == CONFIG_SECTION)) {
+            if (!CONFIG_ITEM(configType) && configType != CONFIG_SECTION)
+                continue;
+
+            if (mod_is_main) {
                 if (categoryItem && [self isSubCategoryGeneral:lastsubcat]) {
                     [[categoryItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&p_configs[j]]];
                 } else if (subCategoryItem) {
                     [[subCategoryItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&p_configs[j]]];
                 }
             }
-            else if (!module_is_main(p_module) && (CONFIG_ITEM(configType) || configType == CONFIG_SECTION)) {
+            else {
                 if (subCategoryItem && ![[subCategoryItem children] containsObject: pluginItem]) {
                     [[subCategoryItem children] addObject:pluginItem];
                 }



More information about the vlc-devel mailing list