Skip to content

Commit ffcca49

Browse files
committed
loader: Simplify extension removing.
It's slightly less efficient, but this happens very rarely (just at instance creation) and the lists of extensions and extensions-to-suppress are both very small, so readability wins out over efficiency.
1 parent 448894e commit ffcca49

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

src/loader/loader_instance.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,14 @@ class InstanceCreateInfoManager {
6969
// Remove extensions named in the parameter and return a pointer to the current state.
7070
const XrInstanceCreateInfo* FilterOutExtensions(const std::vector<const char*>& extensions_to_skip) {
7171
if (enabled_extensions_cstr.empty()) {
72-
return &modified_create_info;
72+
return Get();
7373
}
7474
if (extensions_to_skip.empty()) {
75-
return &modified_create_info;
75+
return Get();
76+
}
77+
for (auto& ext : extensions_to_skip) {
78+
FilterOutExtension(ext);
7679
}
77-
auto b = enabled_extensions_cstr.begin();
78-
auto e = enabled_extensions_cstr.end();
79-
auto shouldSkipExtension = [&](const char* extensionInQuestion) {
80-
auto it = std::find_if(b, e, [&](const char* extension) { return strcmp(extensionInQuestion, extension) == 0; });
81-
return it != extensions_to_skip.end();
82-
};
83-
vector_remove_if_and_erase(enabled_extensions_cstr, shouldSkipExtension);
8480
return Update();
8581
}
8682
// Remove the extension named in the parameter and return a pointer to the current state.

0 commit comments

Comments
 (0)