Browse Source

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.
pull/499/head
Vladimír Vondruš 3 years ago
parent
commit
468d68eed4
  1. 2
      src/Magnum/GL/Context.cpp
  2. 2
      src/Magnum/GL/Context.h
  3. 3
      src/Magnum/GL/Implementation/driverSpecific.cpp

2
src/Magnum/GL/Context.cpp

@ -994,7 +994,7 @@ bool Context::tryCreate(const Configuration& configuration) {
if(!_driverWorkarounds.isEmpty()) { if(!_driverWorkarounds.isEmpty()) {
Debug{output} << "Using driver workarounds:"; Debug{output} << "Using driver workarounds:";
for(const auto& workaround: _driverWorkarounds) 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 /* Fetch default framebuffer size and set up default clear color. If we are

2
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 then can be discarded -- what to do? we could avoid including
Array altogether */ Array altogether */
/* True means known and disabled, false means known */ /* True means known and disabled, false means known */
Containers::Array<std::pair<Containers::StringView, bool>> _driverWorkarounds; Containers::Array<Containers::Pair<Containers::StringView, bool>> _driverWorkarounds;
Containers::Array<Extension> _disabledExtensions; Containers::Array<Extension> _disabledExtensions;
Implementation::ContextConfigurationFlags _configurationFlags; Implementation::ContextConfigurationFlags _configurationFlags;
}; };

3
src/Magnum/GL/Implementation/driverSpecific.cpp

@ -24,6 +24,7 @@
*/ */
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Corrade/Containers/StringIterable.h> #include <Corrade/Containers/StringIterable.h>
@ -612,7 +613,7 @@ bool Context::isDriverWorkaroundDisabled(const Containers::StringView workaround
compare just data pointers instead of the whole string as we store only compare just data pointers instead of the whole string as we store only
the views in the KnownWorkarounds list. */ the views in the KnownWorkarounds list. */
for(const auto& i: _driverWorkarounds) 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); arrayAppend(_driverWorkarounds, InPlaceInit, found, false);
return false; return false;
} }

Loading…
Cancel
Save