Browse Source

Vk: sprinkle a bunch of consts here and there.

euler-xxx
Vladimír Vondruš 5 years ago
parent
commit
8984157db5
  1. 6
      src/Magnum/Vk/Device.cpp
  2. 8
      src/Magnum/Vk/Implementation/DriverWorkaround.cpp
  3. 2
      src/Magnum/Vk/Instance.cpp

6
src/Magnum/Vk/Device.cpp

@ -141,9 +141,9 @@ DeviceCreateInfo::DeviceCreateInfo(DeviceProperties& deviceProperties, const Ext
we don't need to bother with String allocations. */
Containers::StringView disabledWorkarounds = args.value<Containers::StringView>("disable-workarounds");
if(!disabledWorkarounds.isEmpty()) {
Containers::Array<Containers::StringView> split = disabledWorkarounds.splitWithoutEmptyParts();
const Containers::Array<Containers::StringView> split = disabledWorkarounds.splitWithoutEmptyParts();
arrayReserve(_state->encounteredWorkarounds, split.size());
for(Containers::StringView workaround: split)
for(const Containers::StringView workaround: split)
Implementation::disableWorkaround(_state->encounteredWorkarounds, workaround);
}
@ -837,7 +837,7 @@ template<class T> void Device::initializeExtensions(const Containers::ArrayView<
for(const Version version: KnownVersionsForExtensions) {
const Containers::ArrayView<const Extension> knownExtensions =
Extension::extensions(version);
auto found = std::lower_bound(knownExtensions.begin(), knownExtensions.end(), extension, [](const Extension& a, const T& b) {
const auto found = std::lower_bound(knownExtensions.begin(), knownExtensions.end(), extension, [](const Extension& a, const T& b) {
return a.string() < static_cast<const Containers::StringView&>(b);
});
if(found->string() != extension) continue;

8
src/Magnum/Vk/Implementation/DriverWorkaround.cpp

@ -78,8 +78,8 @@ constexpr Containers::StringView KnownWorkarounds[]{
Moreover, based on the experience with GL, I don't expect there being too
many workarounds used heavily (10 at most, maybe?) so I won't bother with
some binary search, which needs extra testing effort. */
Containers::StringView findWorkaround(Containers::StringView workaround) {
for(Containers::StringView i: KnownWorkarounds)
Containers::StringView findWorkaround(const Containers::StringView workaround) {
for(const Containers::StringView i: KnownWorkarounds)
if(workaround == i) return i;
return {};
}
@ -90,7 +90,7 @@ void disableWorkaround(Containers::Array<std::pair<Containers::StringView, bool>
/* Find the workaround. Note that we'll add the found view to the array
and not the passed view, as the found view is guaranteed to stay in
scope */
Containers::StringView found = findWorkaround(workaround);
const Containers::StringView found = findWorkaround(workaround);
/* Ignore unknown workarounds */
/** @todo this will probably cause false positives when both GL and Vulkan
@ -105,7 +105,7 @@ void disableWorkaround(Containers::Array<std::pair<Containers::StringView, bool>
Containers::Array<std::pair<Containers::StringView, bool>> disableAllWorkarounds() {
Containers::Array<std::pair<Containers::StringView, bool>> encounteredWorkarounds;
for(Containers::StringView i: KnownWorkarounds)
for(const Containers::StringView i: KnownWorkarounds)
arrayAppend(encounteredWorkarounds, Containers::InPlaceInit, i, true);
return encounteredWorkarounds;
}

2
src/Magnum/Vk/Instance.cpp

@ -355,7 +355,7 @@ template<class T> void Instance::initializeExtensions(const Containers::ArrayVie
InstanceExtension::extensions(Version::Vk11),
/*InstanceExtension::extensions(Version::Vk12) is empty */
}) {
auto found = std::lower_bound(knownExtensions.begin(), knownExtensions.end(), extension, [](const InstanceExtension& a, const T& b) {
const auto found = std::lower_bound(knownExtensions.begin(), knownExtensions.end(), extension, [](const InstanceExtension& a, const T& b) {
return a.string() < static_cast<const Containers::StringView&>(b);
});
if(found->string() != extension) continue;

Loading…
Cancel
Save