From e68b551faf91b82866967d73fae704ee0e008a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 5 Jun 2019 22:13:56 +0200 Subject: [PATCH] [wip] remove one unordered map and a static constructor / destructor --- src/Magnum/GL/Context.cpp | 52 +++++++++---------- .../GL/Implementation/driverSpecific.cpp | 6 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index 32a3bcf79..5a119be85 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -672,20 +672,20 @@ bool Context::tryCreate() { /* List of extensions from future versions (extensions from current and previous versions should be supported automatically, so we don't need to check for them) */ - std::unordered_map futureExtensions; - for(std::size_t i = future; i != versions.size(); ++i) - for(const Extension& extension: Extension::extensions(versions[i])) - futureExtensions.emplace(extension.string(), extension); - - /* Check for presence of future and vendor extensions */ - const std::vector extensions = extensionStrings(); - for(const std::string& extension: extensions) { - const auto found = futureExtensions.find(extension); - if(found != futureExtensions.end()) { - _supportedExtensions.push_back(found->second); - _extensionStatus.set(found->second.index(), true); - } - } +// std::unordered_map futureExtensions; +// for(std::size_t i = future; i != versions.size(); ++i) +// for(const Extension& extension: Extension::extensions(versions[i])) +// futureExtensions.emplace(extension.string(), extension); +// +// /* Check for presence of future and vendor extensions */ +// const std::vector extensions = extensionStrings(); +// for(const std::string& extension: extensions) { +// const auto found = futureExtensions.find(extension); +// if(found != futureExtensions.end()) { +// _supportedExtensions.push_back(found->second); +// _extensionStatus.set(found->second.index(), true); +// } +// } /* Reset minimal required version to Version::None for whole array */ for(auto& i: _extensionRequiredVersion) i = Version::None; @@ -716,21 +716,21 @@ bool Context::tryCreate() { Debug{output} << "Disabling extensions:"; /* Put remaining extensions into the hashmap for faster lookup */ - std::unordered_map allExtensions{std::move(futureExtensions)}; - for(std::size_t i = 0; i != future; ++i) - for(const Extension& extension: Extension::extensions(versions[i])) - allExtensions.emplace(extension.string(), extension); +// std::unordered_map allExtensions{std::move(futureExtensions)}; +// for(std::size_t i = 0; i != future; ++i) +// for(const Extension& extension: Extension::extensions(versions[i])) +// allExtensions.emplace(extension.string(), extension); /* Disable extensions that are known and supported and print a message for each */ - for(auto&& extension: _disabledExtensions) { - auto found = allExtensions.find(extension); - /** @todo Error message here? I should not clutter the output at this point */ - if(found == allExtensions.end()) continue; - - _extensionRequiredVersion[found->second.index()] = Version::None; - Debug{output} << " " << extension; - } +// for(auto&& extension: _disabledExtensions) { +// auto found = allExtensions.find(extension); +// /** @todo Error message here? I should not clutter the output at this point */ +// if(found == allExtensions.end()) continue; +// +// _extensionRequiredVersion[found->second.index()] = Version::None; +// Debug{output} << " " << extension; +// } } _state.emplace(*this, output); diff --git a/src/Magnum/GL/Implementation/driverSpecific.cpp b/src/Magnum/GL/Implementation/driverSpecific.cpp index c72225b5c..d6ea492c7 100644 --- a/src/Magnum/GL/Implementation/driverSpecific.cpp +++ b/src/Magnum/GL/Implementation/driverSpecific.cpp @@ -36,7 +36,7 @@ namespace Magnum { namespace GL { namespace { /* Search the code for the following strings to see where they are implemented. */ - std::vector KnownWorkarounds{ + const char* KnownWorkarounds[]{ /* [workarounds] */ #if defined(CORRADE_TARGET_ANDROID) && defined(MAGNUM_TARGET_GLES) /* glBeginQuery() with GL_TIME_ELAPSED causes a GL_OUT_OF_MEMORY error when @@ -360,7 +360,7 @@ auto Context::detectedDriver() -> DetectedDrivers { void Context::disableDriverWorkaround(const std::string& workaround) { /* Ignore unknown workarounds */ - if(std::find(KnownWorkarounds.begin(), KnownWorkarounds.end(), workaround) == KnownWorkarounds.end()) { + if(std::find(std::begin(KnownWorkarounds), std::end(KnownWorkarounds), workaround) == std::end(KnownWorkarounds)) { Warning() << "Unknown workaround" << workaround; return; } @@ -368,7 +368,7 @@ void Context::disableDriverWorkaround(const std::string& workaround) { } bool Context::isDriverWorkaroundDisabled(const char* workaround) { - CORRADE_INTERNAL_ASSERT(std::find(KnownWorkarounds.begin(), KnownWorkarounds.end(), workaround) != KnownWorkarounds.end()); + CORRADE_INTERNAL_ASSERT(std::find(std::begin(KnownWorkarounds), std::end(KnownWorkarounds), workaround) != std::end(KnownWorkarounds)); /* If the workaround was already asked for or disabled, return its state, otherwise add it to the list as used one */