1
0
Fork 0
forked from suyu/suyu

consumer_base: Pass shared_ptr by const reference

Avoids churning atomic reference count increments and decrements.
This commit is contained in:
Lioncash 2022-11-28 19:09:41 -05:00
parent 260a495a23
commit c0c4f6dfa6
2 changed files with 6 additions and 6 deletions

View file

@ -83,7 +83,7 @@ Status ConsumerBase::AcquireBufferLocked(BufferItem* item, std::chrono::nanoseco
} }
Status ConsumerBase::AddReleaseFenceLocked(s32 slot, Status ConsumerBase::AddReleaseFenceLocked(s32 slot,
const std::shared_ptr<GraphicBuffer> graphic_buffer, const std::shared_ptr<GraphicBuffer>& graphic_buffer,
const Fence& fence) { const Fence& fence) {
LOG_DEBUG(Service_NVFlinger, "slot={}", slot); LOG_DEBUG(Service_NVFlinger, "slot={}", slot);
@ -100,7 +100,7 @@ Status ConsumerBase::AddReleaseFenceLocked(s32 slot,
} }
Status ConsumerBase::ReleaseBufferLocked(s32 slot, Status ConsumerBase::ReleaseBufferLocked(s32 slot,
const std::shared_ptr<GraphicBuffer> graphic_buffer) { const std::shared_ptr<GraphicBuffer>& graphic_buffer) {
// If consumer no longer tracks this graphic_buffer (we received a new // If consumer no longer tracks this graphic_buffer (we received a new
// buffer on the same slot), the buffer producer is definitely no longer // buffer on the same slot), the buffer producer is definitely no longer
// tracking it. // tracking it.
@ -121,7 +121,7 @@ Status ConsumerBase::ReleaseBufferLocked(s32 slot,
} }
bool ConsumerBase::StillTracking(s32 slot, bool ConsumerBase::StillTracking(s32 slot,
const std::shared_ptr<GraphicBuffer> graphic_buffer) const { const std::shared_ptr<GraphicBuffer>& graphic_buffer) const {
if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) { if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
return false; return false;
} }

View file

@ -36,9 +36,9 @@ protected:
void FreeBufferLocked(s32 slot_index); void FreeBufferLocked(s32 slot_index);
Status AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when); Status AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when);
Status ReleaseBufferLocked(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer); Status ReleaseBufferLocked(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer);
bool StillTracking(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer) const; bool StillTracking(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer) const;
Status AddReleaseFenceLocked(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer, Status AddReleaseFenceLocked(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer,
const Fence& fence); const Fence& fence);
struct Slot final { struct Slot final {