2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

buffer_queue: Make use of std::nullopt

Allows compilers to eliminate unnecessary zeroing out of the optional's
buffer.
This commit is contained in:
Lioncash 2020-08-03 09:26:34 -04:00
parent 24bd068a08
commit 9b837c6069

View file

@ -38,7 +38,7 @@ std::optional<std::pair<u32, Service::Nvidia::MultiFence*>> BufferQueue::Dequeue
u32 height) { u32 height) {
if (free_buffers.empty()) { if (free_buffers.empty()) {
return {}; return std::nullopt;
} }
auto f_itr = free_buffers.begin(); auto f_itr = free_buffers.begin();
@ -69,7 +69,7 @@ std::optional<std::pair<u32, Service::Nvidia::MultiFence*>> BufferQueue::Dequeue
} }
if (itr == queue.end()) { if (itr == queue.end()) {
return {}; return std::nullopt;
} }
itr->status = Buffer::Status::Dequeued; itr->status = Buffer::Status::Dequeued;
@ -103,14 +103,15 @@ std::optional<std::reference_wrapper<const BufferQueue::Buffer>> BufferQueue::Ac
auto itr = queue.end(); auto itr = queue.end();
// Iterate to find a queued buffer matching the requested slot. // Iterate to find a queued buffer matching the requested slot.
while (itr == queue.end() && !queue_sequence.empty()) { while (itr == queue.end() && !queue_sequence.empty()) {
u32 slot = queue_sequence.front(); const u32 slot = queue_sequence.front();
itr = std::find_if(queue.begin(), queue.end(), [&slot](const Buffer& buffer) { itr = std::find_if(queue.begin(), queue.end(), [&slot](const Buffer& buffer) {
return buffer.status == Buffer::Status::Queued && buffer.slot == slot; return buffer.status == Buffer::Status::Queued && buffer.slot == slot;
}); });
queue_sequence.pop_front(); queue_sequence.pop_front();
} }
if (itr == queue.end()) if (itr == queue.end()) {
return {}; return std::nullopt;
}
itr->status = Buffer::Status::Acquired; itr->status = Buffer::Status::Acquired;
return *itr; return *itr;
} }