From 51132fa278e6bba1df546076beda94c1c0cb6a2f Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Fri, 12 Sep 2025 16:09:12 -0500 Subject: [PATCH 1/2] Prevent unnecessary allocations in test util We can use string_view's to prevent allocating a string every time get_folder_for_given_path is called. --- tests/framework/util/folder_manager.cpp | 16 +++++++--------- tests/framework/util/folder_manager.h | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/framework/util/folder_manager.cpp b/tests/framework/util/folder_manager.cpp index c406309ed..53bbba661 100644 --- a/tests/framework/util/folder_manager.cpp +++ b/tests/framework/util/folder_manager.cpp @@ -187,20 +187,18 @@ FileSystemManager::FileSystemManager() fs::Folder& FileSystemManager::get_folder(ManifestLocation location) noexcept { return folders.at(location); } fs::Folder const& FileSystemManager::get_folder(ManifestLocation location) const noexcept { return folders.at(location); } -Folder* FileSystemManager::get_folder_for_given_path(std::filesystem::path const& given_path) noexcept { - auto normalized_path = given_path.lexically_normal(); +Folder* FileSystemManager::get_folder_for_given_path(std::string_view given_path) noexcept { for (auto const& [manifest_location, folder] : folders) { - if (folder.location() == normalized_path) { + if (folder.location() == given_path) { return &folders.at(manifest_location); } } - if (redirected_paths.count(given_path.string()) > 0) { - return &folders.at(redirected_paths.at(normalized_path.string())); - } - for (auto const& [redirected_path_str, redirected_location] : redirected_paths) { - std::filesystem::path redirected_path = redirected_path_str; + for (auto const& [redirected_path, redirected_location] : redirected_paths) { + if (redirected_path == given_path) { + return &folders.at(redirected_location); + } const auto mismatch_pair = - std::mismatch(normalized_path.begin(), normalized_path.end(), redirected_path.begin(), redirected_path.end()); + std::mismatch(given_path.begin(), given_path.end(), redirected_path.begin(), redirected_path.end()); if (mismatch_pair.second == redirected_path.end()) return &folders.at(redirected_location); } return nullptr; diff --git a/tests/framework/util/folder_manager.h b/tests/framework/util/folder_manager.h index 68e69c211..9d405cbb3 100644 --- a/tests/framework/util/folder_manager.h +++ b/tests/framework/util/folder_manager.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -87,7 +88,7 @@ class FileSystemManager { Folder const& get_folder(ManifestLocation location) const noexcept; // Gets a pointer to the folder that given_path points to. This includes redirected paths as well as the exact path of folders - Folder* get_folder_for_given_path(std::filesystem::path const& given_path) noexcept; + Folder* get_folder_for_given_path(std::string_view given_path) noexcept; bool is_folder_path(std::filesystem::path const& path) const noexcept; From e5945179dc2c9decc22936c751fc3d91c04aa4a4 Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Fri, 12 Sep 2025 16:10:06 -0500 Subject: [PATCH 2/2] Initialize enabled_extensions in TestICD code Uninitialized memory triggers a runtime check that drastically slows down test execution. --- tests/framework/icd/test_icd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/framework/icd/test_icd.cpp b/tests/framework/icd/test_icd.cpp index 466293a55..1cc964c35 100644 --- a/tests/framework/icd/test_icd.cpp +++ b/tests/framework/icd/test_icd.cpp @@ -1723,7 +1723,7 @@ bool should_check(std::vector* exts, VkDevice device, const char* e } PFN_vkVoidFunction get_device_func(VkDevice device, const char* pName) { - std::vector* enabled_extensions; + std::vector* enabled_extensions = nullptr; FindDevice found_device{}; if (device != nullptr) { found_device = lookup_device(device);