From 468d68eed475aea7446fbf8c0c490abd1387354f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 30 Dec 2022 22:12:41 +0100 Subject: [PATCH] GL: don't use std::pair in Context internals. And this, this change allows the growable Array to use malloc() instead of new, and thus also realloc(), saving unnecessary reallocations if the memory can be grown in-place. All because Containers::Pair is trivially copyable while std::pair wasn't. There isn't any good reason to use the STL anymore. --- src/Magnum/GL/Context.cpp | 2 +- src/Magnum/GL/Context.h | 2 +- src/Magnum/GL/Implementation/driverSpecific.cpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index b2542d3ee..49175e6cb 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -994,7 +994,7 @@ bool Context::tryCreate(const Configuration& configuration) { if(!_driverWorkarounds.isEmpty()) { Debug{output} << "Using driver workarounds:"; for(const auto& workaround: _driverWorkarounds) - if(!workaround.second) Debug(output) << " " << workaround.first; + if(!workaround.second()) Debug(output) << " " << workaround.first(); } /* Fetch default framebuffer size and set up default clear color. If we are diff --git a/src/Magnum/GL/Context.h b/src/Magnum/GL/Context.h index 22e844be2..8b1a543d4 100644 --- a/src/Magnum/GL/Context.h +++ b/src/Magnum/GL/Context.h @@ -915,7 +915,7 @@ class MAGNUM_GL_EXPORT Context { then can be discarded -- what to do? we could avoid including Array altogether */ /* True means known and disabled, false means known */ - Containers::Array> _driverWorkarounds; + Containers::Array> _driverWorkarounds; Containers::Array _disabledExtensions; Implementation::ContextConfigurationFlags _configurationFlags; }; diff --git a/src/Magnum/GL/Implementation/driverSpecific.cpp b/src/Magnum/GL/Implementation/driverSpecific.cpp index f3ad80a69..281b1b92d 100644 --- a/src/Magnum/GL/Implementation/driverSpecific.cpp +++ b/src/Magnum/GL/Implementation/driverSpecific.cpp @@ -24,6 +24,7 @@ */ #include +#include #include #include @@ -612,7 +613,7 @@ bool Context::isDriverWorkaroundDisabled(const Containers::StringView workaround compare just data pointers instead of the whole string as we store only the views in the KnownWorkarounds list. */ for(const auto& i: _driverWorkarounds) - if(i.first.data() == found.data()) return i.second; + if(i.first().data() == found.data()) return i.second(); arrayAppend(_driverWorkarounds, InPlaceInit, found, false); return false; }