SF: Clean up ftl::SmallMap lookup fallbacks
Avoid std::cref to a local variable, which is not intuitive and incurs
construction in the non-fallback case.
Bug: 185536303
Test: ftl_test
Change-Id: I1c5a94bdab105a04f8230fe762bdc433eea5c97a
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index 720a1cb..4b2983b 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -32,6 +32,7 @@
#include <ui/GraphicTypes.h>
#pragma clang diagnostic pop // ignored "-Wconversion -Wextra"
+#include <ftl/algorithm.h>
#include <ftl/fake_guard.h>
#include <ftl/optional.h>
#include <scheduler/Features.h>
@@ -438,13 +439,13 @@
RefreshRateSelectorPtr pacesetterSelectorPtrLocked() const REQUIRES(mDisplayLock) {
ftl::FakeGuard guard(kMainThreadContext);
- const RefreshRateSelectorPtr noPacesetter;
return mPacesetterDisplayId
.and_then([this](PhysicalDisplayId pacesetterId)
REQUIRES(mDisplayLock, kMainThreadContext) {
return mRefreshRateSelectors.get(pacesetterId);
})
- .value_or(std::cref(noPacesetter));
+ .or_else(ftl::static_ref<RefreshRateSelectorPtr>([] { return nullptr; }))
+ .value();
}
std::shared_ptr<const VsyncSchedule> getVsyncScheduleLocked(