Skip to content

Commit

Permalink
Fix: Move objects/vectors where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda authored and charles-lunarg committed Jan 30, 2024
1 parent dd6c02e commit 6119bfc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/VkBootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ PhysicalDeviceSelector& PhysicalDeviceSelector::add_desired_extension(const char
criteria.desired_extensions.push_back(extension);
return *this;
}
PhysicalDeviceSelector& PhysicalDeviceSelector::add_desired_extensions(std::vector<const char*> extensions) {
PhysicalDeviceSelector& PhysicalDeviceSelector::add_desired_extensions(const std::vector<const char*>& extensions) {
for (const auto& ext : extensions) {
criteria.desired_extensions.push_back(ext);
}
Expand Down Expand Up @@ -1480,22 +1480,22 @@ DispatchTable Device::make_table() const { return { device, fp_vkGetDeviceProcAd
Device::operator VkDevice() const { return this->device; }

CustomQueueDescription::CustomQueueDescription(uint32_t index, std::vector<float> priorities)
: index(index), priorities(priorities) {}
: index(index), priorities(std::move(priorities)) {}

void destroy_device(Device const& device) {
device.internal_table.fp_vkDestroyDevice(device.device, device.allocation_callbacks);
}

DeviceBuilder::DeviceBuilder(PhysicalDevice phys_device) { physical_device = phys_device; }
DeviceBuilder::DeviceBuilder(PhysicalDevice phys_device) { physical_device = std::move(phys_device); }

Result<Device> DeviceBuilder::build() const {

std::vector<CustomQueueDescription> queue_descriptions;
queue_descriptions.insert(queue_descriptions.end(), info.queue_descriptions.begin(), info.queue_descriptions.end());

if (queue_descriptions.size() == 0) {
if (queue_descriptions.empty()) {
for (uint32_t i = 0; i < physical_device.queue_families.size(); i++) {
queue_descriptions.push_back(CustomQueueDescription{ i, std::vector<float>{ 1.0f } });
queue_descriptions.emplace_back(i, std::vector<float>{ 1.0f });
}
}

Expand Down Expand Up @@ -1527,7 +1527,7 @@ Result<Device> DeviceBuilder::build() const {
}
}

if (user_defined_phys_dev_features_2 && physical_device.extended_features_chain.size() > 0) {
if (user_defined_phys_dev_features_2 && !physical_device.extended_features_chain.empty()) {
return { DeviceError::VkPhysicalDeviceFeatures2_in_pNext_chain_while_using_add_required_extension_features };
}

Expand Down Expand Up @@ -1585,7 +1585,7 @@ Result<Device> DeviceBuilder::build() const {
return device;
}
DeviceBuilder& DeviceBuilder::custom_queue_setup(std::vector<CustomQueueDescription> queue_descriptions) {
info.queue_descriptions = queue_descriptions;
info.queue_descriptions = std::move(queue_descriptions);
return *this;
}
DeviceBuilder& DeviceBuilder::set_allocation_callbacks(VkAllocationCallbacks* callbacks) {
Expand Down Expand Up @@ -1896,7 +1896,7 @@ Result<std::vector<VkImageView>> Swapchain::get_image_views() { return get_image
Result<std::vector<VkImageView>> Swapchain::get_image_views(const void* pNext) {
const auto swapchain_images_ret = get_images();
if (!swapchain_images_ret) return swapchain_images_ret.error();
const auto swapchain_images = swapchain_images_ret.value();
const auto& swapchain_images = swapchain_images_ret.value();

bool already_contains_image_view_usage = false;
while (pNext) {
Expand Down
2 changes: 1 addition & 1 deletion src/VkBootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ class PhysicalDeviceSelector {
// Prefer a physical device which supports a specific extension.
[[deprecated]] PhysicalDeviceSelector& add_desired_extension(const char* extension);
// Prefer a physical device which supports a set of extensions.
[[deprecated]] PhysicalDeviceSelector& add_desired_extensions(std::vector<const char*> extensions);
[[deprecated]] PhysicalDeviceSelector& add_desired_extensions(const std::vector<const char*>& extensions);

// Prefer a physical device that supports a (major, minor) version of vulkan.
[[deprecated("Use set_minimum_version + InstanceBuilder::require_api_version.")]] PhysicalDeviceSelector&
Expand Down

0 comments on commit 6119bfc

Please sign in to comment.