Remove redundant clear when scanning for layers
authorCharles Giessen <charles@lunarg.com>
Sat, 6 May 2023 04:06:24 +0000 (22:06 -0600)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Mon, 29 May 2023 23:45:08 +0000 (17:45 -0600)
All callers of loader_scan_for_implicit_layers and loader_scan_for_layers
clear out instance_layers before calling, making the call to
loader_delete_layer_list_and_properties redundant.

Also reordered the local variable declaration order to match.

loader/loader.c

index c35a65406c612f986dd8bccb88d5a28d62eb1e34..68c0072032f6be9402ec8c58200c49e9c27fbc90 100644 (file)
@@ -3830,9 +3830,6 @@ VkResult loader_scan_for_layers(struct loader_instance *inst, struct loader_laye
         goto out;
     }
 
-    // Cleanup any previously scanned libraries
-    loader_delete_layer_list_and_properties(inst, instance_layers);
-
     // Get a list of manifest files for any implicit layers
     res = loader_get_data_files(inst, LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER, NULL, &manifest_files);
     if (VK_SUCCESS != res) {
@@ -3963,15 +3960,15 @@ out:
 }
 
 VkResult loader_scan_for_implicit_layers(struct loader_instance *inst, struct loader_layer_list *instance_layers) {
-    struct loader_envvar_filter enable_filter;
-    struct loader_envvar_disable_layers_filter disable_filter;
+    VkResult res = VK_SUCCESS;
     char *file_str;
     struct loader_data_files manifest_files;
     cJSON *json = NULL;
     bool override_layer_valid = false;
     char *override_paths = NULL;
     bool implicit_metalayer_present = false;
-    VkResult res = VK_SUCCESS;
+    struct loader_envvar_filter enable_filter;
+    struct loader_envvar_disable_layers_filter disable_filter;
 
     // Before we begin anything, init manifest_files to avoid a delete of garbage memory if
     // a failure occurs before allocating the manifest filename_list.
@@ -3992,9 +3989,6 @@ VkResult loader_scan_for_implicit_layers(struct loader_instance *inst, struct lo
         goto out;
     }
 
-    // Cleanup any previously scanned libraries
-    loader_delete_layer_list_and_properties(inst, instance_layers);
-
     for (uint32_t i = 0; i < manifest_files.count; i++) {
         file_str = manifest_files.filename_list[i];
         if (file_str == NULL) {